Matt Cassel will be back as the Vikings quarterback … but with a better deal.

Cassel agreed to terms with the Vikings on a two-year contract Friday, exactly four weeks after he opted out of his previous contract and became a free agent.

The signing was confirmed by two NFL sources. The contract Cassel opted out of was a two-year deal he signed in 2013 that was worth $3.7 million per season. His new contract is worth $10 million over two years, according to cbssports.com.

The two sides agreed to terms while the Vikings had exclusive negotiating rights before the three-day NFL free agency negotiation period opens at 11 a.m. Saturday. Players cannot officially sign with a new club until free agency begins at 3 p.m. Tuesday.

The Vikings are around $36 million below the NFL's salary cap of $133 million entering free agency.

The signing of a quarterback should allow the Vikings to spend most of that money addressing their defensive weaknesses. The team was 31st in the NFL last season in defense and fired coach Leslie Frazier after a 5-11-1 season, hiring Cincinnati defensive coordinator Mike Zimmer in January.

Vikings General Manager Rick Spielman said last week the Vikings intended to add a quarterback in free agency and also intend to draft one in May, but has made it clear that doesn't mean the team will take a quarterback in the first round. The Vikings have the eighth overall pick.

Cassel likely would be the veteran presence and a "bridge" to the time when a rookie quarterback could get up to speed and possibly take over.

Jacksonville, which is need of a quarterback and has the third overall pick on May 8, signed its "bridge" quarterback, Chad Henne, to a two-year deal worth a reported $8 million earlier Friday.

Christian Ponder, who began 2013 as the Vikings starter before Cassel ended up starting the final four games, will be in the final season of his four-year rookie contract in 2014.

The top quarterbacks for this year's draft are Teddy Bridgewater of Louisville, Blake Bortles of Central Florida, Johnny Manziel of Texas A & M and Derek Carr of Fresno State.

Cassel, 31, last spoke with reporters after the Vikings' season-ending 14-13 victory over the Lions.

"I love playing for the Vikings," he said. "The fan base here is absolutely amazing. The team was special. It was a great team to play for. I really enjoyed my time with my wife, myself, my kids, a great community and everything else that goes along with it. So, would I love to be a Minnesota Viking? Absolutely, without a doubt."

Cassel played in nine games for the Vikings last season, starting six. He was 25th in the NFL in passer rating (81.6).

Cassel was a backup to Heisman winners Matt Leinart and Carson Palmer at USC, and is the only modern-era quarterback who never started a college game to have started an NFL game.

The Patriots drafted Cassel in the seventh round (230th overall) in 2005. He backed up Tom Brady for four seasons, but took over in 2008 when Brady suffered a knee injury and led New England to an 11-5 record.

The Patriots traded him to Kansas City in 2009 and he played four seasons for the Chiefs, making the Pro Bowl in 2010.

Ponder, the 12th pick in the 2011 draft, signed a four-year contract for $10.15 million that is fully guaranteed. His signing bonus of $5.8 million is paid out evenly over the four years.