The Nick Foles sweepstakes are officially over, and it looks like the Cowboys aren't going to go home happy.

According to NFL.com, Foles has agreed to terms with the Kansas City Chiefs in a move that will reunite the quarterback with the coach who originally drafted him.

Foles' NFL career started in 2012 after the Eagles selected him in the third round of the NFL Draft. The coach of the Eagles at the time was Andy Reid, who is now coaching the Chiefs.

Under Reid's direction in 2012, Foles started six games for the Eagles and went 1-5. When Reid drafted Foles, he made the move with the assumption that the former Arizona quarterback would later be the Eagles' full-time starter.

However, Reid didn't get to see his plan through because he was fired in Philly after the 2012 season. But Reid liked Foles so much that he tried to trade for him during his first year in Kansas City in 2013, according to USA Today.

andy-reid-nick-foles-eagles.jpg
Reunited and it feels so good. USATSI

Reid's familiarity with Foles isn't the only reason the the Chiefs decided to add the former Rams quarterback. The Chiefs lost backup quarterback Chase Daniel in March after he decided to sign with the Eagles, which means Foles will likely make an immediate jump to the backup quarterback spot in Kansas City behind Alex Smith and ahead of Aaron Murray.

Foles' late-night decision to sign with the Chiefs ended a week-long sweepstakes that didn't really get interesting until Tuesday when Cowboys backup quarterback Kellen Moore broke his right ankle during practice.

After the injury, Foles became an immediate candidate to back up Tony Romo in Dallas. According to NFL.com, the Cowboys were one of three teams to offer a contract to Foles on Wednesday night. Besides Dallas and Kansas City, Foles also received an offer from the Vikings.

In the end, Foles agreed on a one-year deal with the Chiefs that includes a team option for a second year, according to ESPN.com. The deal will pay Foles $1.75 million in 2016, and then will pay him between $6.75 million to $16 million in 2016, depending on whether or not he gets any playing time in Kansas City this season.

Foles had been a free agent since July 27 when he was released by the Rams. Foles spent one season with the Rams and likely knew he wasn't going to last much longer with the team after they drafted Jared Goff with the No. 1 overall pick in this year's draft.