Giancarlo Stanton, the 25-year-old National League MVP runner-up, and the Miami Marlins, baseball’s prodigal franchise, agreed to a 13-year, $325 million contract extension.

The richest contract in sports history could keep Stanton in Miami through 2027, when Stanton would be approaching his 38th birthday. The Marlins agreed to include a no-trade clause and an opt-out opportunity after six years. Both are unusual for the Marlins, but speak to past practices that have made them an unstable franchise and unattractive to high-end free agents. The mammoth deal was confirmed by various media outlets Monday.

Stanton was two years from free agency. In recent months, he’d seemed reluctant to commit to an organization whose direction had frequently changed, perhaps at the whims of owner Jeffrey Loria and president David Samson.

View photos Giancarlo Stanton's deal includes a no-trade clause and an opt-out after six years. (AP) More

The Marlins’ payroll was $102 million in 2012, when they stunned the industry by signing Jose Reyes, Mark Buehrle and Heath Bell to large contracts. By mid-summer they were off-loading those contracts and others, and by 2013 and ’14 the payroll was half that.

Still a core of young players emerged. The Marlins won 77 games last season, the most in four years, and did not finish last in the NL East for the first time in the same span.

As he crept up on free agency, Stanton frequently said he valued winning over all else. Asked in August if the progress shown over the season had changed his regard for the franchise, he responded, “Five months doesn’t change five years.”

That said, it’s likely he viewed $325 million – $50 million more than the previous highest contract, that being Alex Rodriguez’s $275 million over 10 years signed in 2007– as a reason to reconsider. The Marlins could attempt to sign several of their own young players – pitcher Jose Fernandez, shortstop Adeiny Hechavarria and outfielder Christian Yelich, among them – to contract extensions, which Stanton might have taken as a sign of newfound organizational commitment and stability.

The risk Stanton takes is the Marlins still do not draw at Marlins Park, still do not win because Stanton’s contract makes it difficult to afford other free agents, Loria reconsiders the huge financial outlay that does not produce immediate results, and Stanton finds himself in a career-long slog to irrelevance. That, presumably, is what the opt-out clause is for.

The change of heart also might have its roots in a game Stanton played Sept. 11 in Milwaukee. In the fifth inning, he was hit in the face by a Mike Fiers fastball and missed the remainder of the season. Numerous surgeries followed. He said last month he continues his recovery and expects to be healthy come spring training. His doctor told him he’d narrowly missed a much more serious injury, one that could have threatened his career.

“You understand,” Stanton said, “how things can happen.”

So, it appears, Stanton, for a long time suspicious of the organization and Loria in particular, was swayed by self-preservation, the sincerity of president of baseball operations Mike Hill and general manager Dan Jennings, the promise of better things in Miami, and, yeah, the $325 million.

What the Marlins get in return is a young, strong, good-looking slugger and outfielder who, at 24, had his most productive season. He led the NL with 37 home runs and in slugging percentage and total bases, in spite of missing the season’s final three weeks. He finished second in NL MVP balloting to Clayton Kershaw.

Story continues