After nearly two years on the bench, Mark Sanchez replaced an injured Nick Foles, overcame turnovers and did enough to keep the Eagles in first place.

Foles hurt his left shoulder late in the first quarter, and Sanchez came on to threw for 202 yards and two touchdowns to lead Philadelphia to a 31-21 win over the Houston Texans on Sunday.

Sanchez, who also threw two interceptions, missed all of last season after tearing the labrum in his right shoulder in the preseason. He last played on Dec. 30, 2012 with the New York Jets.

The Eagles (6-2) led by 3 when Jeremy Maclin grabbed a low throw from Sanchez for an 8-yard touchdown to make it 31-21 with about four minutes remaining.

Ryan Fitzpatrick threw for 203 yards with two touchdowns and an interception for Houston (4-5).

Maclin finished with two touchdowns and 158 yards receiving and LeSean McCoy had 117 yards rushing.

It was the second straight big game for Maclin, who had a career-high 187 yards receiving last week. Maclin missed all of last season after a second ACL surgery. His 59-yard touchdown reception in the first quarter on Sunday was his third TD of 50 yards or longer this season.

The Eagles were up by 10 and driving late in the third quarter when Jumal Rolle grabbed his second interception of the game.

DeMeco Ryans intercepted Fitzpatrick at the Philadelphia 10, but he hurt his ankle on the play and fumbled the ball as he fell to the ground. DeAndre Hopkins recovered for Houston and scored on a 7-yard reception two plays later to cut the lead to 24-21.

Top overall pick Jadeveon Clowney (illness) and linebacker Brian Cushing (knee) were inactive for the Texans and they lost starting cornerbacks Johnathan Joseph (concussion) and Kareem Jackson (knee) to injuries in the first quarter.

Houston's defense got to the quarterback early, with four sacks in the first half. The Eagles had allowed just two in the previous six games.

Whitney Mercilus sacked Foles twice in three plays, driving him hard into the turf on the second one to send the quarterback to the locker room.

Sanchez didn't waste any time in his Philadelphia debut, finding Maclin deep on his first play for a 52-yard gain. Five plays later, he threw a perfect pass to Jordan Matthews for an 11-yard touchdown to make it 14-7.

Houston tied it up when Arian Foster grabbed a 56-yard TD pass about four minutes before halftime. Foster dashed away from a diving Connor Barwin after the reception on his way to the end zone. That score was set up when receiver Josh Huff tipped a pass by Sanchez that was intercepted by Rolle.

A 45-yard field goal by Cody Parkey gave the Eagles a 17-14 lead at halftime.

Houston missed a 39-yard field goal in the third quarter. The Eagles used four straight running plays capped by an 8-yard run by Chris Polk after that to extend their lead to 24-14 with about three minutes left in the third.

The Associated Press contributed to this report.