Carson Wentz agreed to terms on a four-year contract extension with the Eagles on Thursday night, a landmark deal through the 2024 season that includes the most guaranteed money in NFL history despite the franchise quarterback finishing the last two seasons sidelined with major injuries.

Wentz, 26, already was under contract for two more seasons. The four-year extension is worth $128 million, with more than $107 million guaranteed, a league source confirmed. The guaranteed salary eclipses that of Seattle quarterback Russell Wilson, who received $107 million guaranteed in April. The average annual salary would place him behind Wilson, Pittsburgh’s Ben Roethlisberger, and Green Bay’s Aaron Rodgers among NFL quarterbacks.

It’s certainly the biggest contract in franchise history, surpassing Donovan McNabb’s 12-year, $115-million contract signed in 2002, and Fletcher Cox’s six-year, $103-million contract signed in 2016.

“Can’t even explain to you how excited I am right now to be a part of this great city for this many more years,” Wentz said in a video statement on social media. “It means the world to me. From the moment I got drafted here, I knew this place was special. I knew they had the most passionate fans in the world in all of sports, and I knew we had the opportunity to build something truly special. To be cemented here for this much longer means the world to me.”

Wentz became eligible to sign a contract extension this offseason, and the Eagles wasted little time. Eagles management often remains coy when discussing contracts, but they made no secret in recent months about their desire to turn the speculation into reality. Top executive Howie Roseman said in March that keeping Wentz in Philadelphia long term “is our goal” and that their commitment to signing Wentz to an extension “goes without saying.” He also acknowledged it was a factor in how the team approached its roster building.

Owner Jeffrey Lurie said in March that he had no reservations about signing Wentz to a lucrative contract, even though Wentz tore the anterior cruciate ligament in his left knee in December 2017 and was shelved in December 2018 because of a stress fracture in his back. The Eagles could have waited another year for Wentz to prove he could remain healthy, but they were already convinced that Wentz is the face of the franchise. They even let Super Bowl MVP Nick Foles leave in free agency, secure in their commitment to Wentz.

“When you draw it up, he’s exactly what you want,” Lurie said. “Highly competitive, type-A personality. Demanding. Very smart. Obsessed with winning and winning big. Respected by everyone. Can’t draw it up much better.”

This was a deal the Eagles knew could happen since the spring of 2016, when they made a series of trades to land the No. 2 overall pick so they could bring Wentz to Philadelphia.

In 40 games, Wentz has already accumulated 10,152 yards, 70 touchdowns, a 63.7 percent completion percentage, and a 92.5 passer rating. He was a front-runner for MVP in 2017 before injuring his knee one play before he set the Eagles’ single-season passing record of 33 touchdowns.

Wentz’s performances were uneven last season, showing flashes of brilliance but not leading the team to the same success as the previous season before he was shut down so his back could heal. But Wentz has been a full participant in team workouts this spring, even shedding the knee brace he wore all last season. And he said he has transformed his body this offseason through a focus on diet, nutrition, and training techniques to “help going forward staying healthy and with longevity.”

“Gosh, he’s strong,” coach Doug Pederson said this week. “His lower body is strong. His arm is strong. You are seeing the things that we saw a couple of years ago, when he was healthy, obviously. He’s leading the offense, leading the team, and really doing a nice job out there.”

Although there was risk for the Eagles in signing Wentz to this deal after two injury-shortened campaigns, there also could have been risk in waiting. Wentz’s price tag would only have risen with a standout season. With other young quarterbacks such as the Los Angeles Rams’ Jared Goff and Dallas’ Dak Prescott eligible for new deals and Kansas City’s reigning MVP Patrick Mahomes eligible next offseason, the going rate for franchise quarterbacks was getting more expensive.

Wentz will be 31 when this contract expires. If he remains healthy, he’ll still be in his prime and can land another landmark deal.

There were no questions about Wentz’s standing with the team internally, but the new contract sends a clear message of the team’s confidence in the quarterback. It comes during an offseason that started with a report casting Wentz as the problem with the Eagles’ 2018 season, labeling him as “selfish” and “uncompromising.” Wentz later admitted that the last year “hasn’t been the easiest” for him while struggling through injuries, and he realized he was “emotionally kind of all over the place,” although he denied specific examples in the story.

That’s all prologue now. The Eagles have Wentz locked into a long-term contract, just as they wanted, and they know they’ll go as far as their franchise quarterback takes them – for at least the next six seasons.

“It’s going to be a fun ride,” Wentz said in his online video. “By no means is the work done. We’re just getting started. This year’s going to be special. And I look forward to seeing you guys on Sundays at the Linc this fall.”

Staff writer Jeff McLane contributed to this report