Mattingly interviewed with the Marlins on Monday, and he had been in serious negotiations since. Vice Sports first reported the four-year deal was done on Thursday morning.
An agreement was fully expected. The Marlins have yet to make an official announcement, which is likely to occur after the World Series.
Marlins president of baseball operations Michael Hill on Thursday night was vague on the team's managerial situation.
"We are working on it," Hill said while not naming Mattingly specifically.
Mattingly becomes the Marlins' 10th manager since Loria assumed ownership in 2002. The number could be 11 if you count Brandon Hyde serving one day in the chair in 2011, the day before Jack McKeon agreed to return for his second stint. Hyde filled in after Edwin Rodriguez stepped down in June of that year.
Mattingly replaces Dan Jennings, the general manager who replaced Mike Redmond on May 18, during a season in which Miami finished 71-91.
Jennings' status with the organization was cleared up later Thursday, when he was dismissed. Although the team announced on Oct. 6 that Jennings would return as GM, he had not returned to his old job. He also hadn't been involved in any team decisions since the end of the season. He has a contract that runs through 2018.
As for the managerial search, Miami also interviewed Larry Bowa (twice), Bo Porter, Manny Acta and Phil Nevin. Although the team was prepared to do a wide search, they were closely monitoring Mattingly's situation.
After the Dodgers were eliminated by the Mets in the National League Division Series, the Marlins waited to see if Mattingly would remain with Los Angeles.
Mattingly managed the Dodgers from 2011-15, posting a 446-363 record, including three straight NL West crowns.
The Marlins have not had a winning season since 2009.
Earlier this week, Mattingly was a guest on Dan Patrick's nationally syndicated radio show, and the 54-year-old spoke of his strong interest in the Marlins.
"I got a chance to meet with some of their people and that went really well for me," he said. "I like their guys and we'll see where it goes."
The Marlins have a talented, young core of players, including All-Stars Giancarlo Stanton, Dee Gordon and Jose Fernandez.
As a player, Mattingly was a Yankees icon, known as "Donnie Baseball." The former first baseman was a career .307 hitter in 14 seasons with New York, the American League batting champion in 1984 and AL Most Valuable Player in 1985.