PHILADELPHIA (AP) Nick Foles ran back onto the field after a hard shot knocked him out for a play and the crowd roared, seemingly knowing he was about to do it again.

Jake Elliott kicked a 35-yard field goal as time expired after Foles led the offense into position and the Philadelphia Eagles beat the Houston Texans 32-30 Sunday to keep their playoff hopes alive.

''Foles was so confident and everyone was so calm,'' said Zach Ertz, who set a single-season record for most receptions for tight ends. ''No one flinched. Guys stuck together.''

Foles threw for a franchise-record 471 yards.

The defending Super Bowl champion Eagles (8-7) need a win at Washington (7-8) next week and for Minnesota (8-6-1) to lose at home to Chicago (11-4) to get a wild-card berth.

The Texans (10-5) missed an opportunity to clinch the AFC South and also allowed New England (10-5) to take control of the No. 2 seed. But when Pittsburgh lost to New Orleans, Houston earned at least a wild-card berth.

The Texans would secure the division title with a victory against Jacksonville next week. They'd get a first-round bye with a win and if the Patriots lose or tie.

''I'll put that on my shoulders,'' J.J. Watt said. ''The offense did a great job giving us a chance, and we just didn't get a stop at the end.''

Filling in for the injured Carson Wentz for the second straight week, Foles again played like the Super Bowl MVP who led Philadelphia to a victory over New England.

''We stuck together through the ups and downs,'' said Foles, who choked up when asked about possibly playing his last game in Philadelphia.

Deshaun Watson had two TD passes and ran for two scores.

Watson threw a 35-yard touchdown pass to Vyncint Smith with 2:04 remaining as Houston rallied from a 13-point deficit.

But Foles brought Philadelphia back.

Foles was injured on a late hit by Jadeveon Clowney while completing a 19-yard pass to Alshon Jeffery to the Texans 30 on third-and-10. Nate Sudfeld came in and threw an incomplete pass, but Foles returned on the next play. His 20-yard pass to Ertz on third-and-10 put Philadelphia at the Houston 35.

The Eagles ran the clock down and Elliott made the kick to make up for missing an extra point earlier in the quarter.

''When it ends a game, you get to enjoy it a little bit longer,'' Elliott said.

Watson threw a 14-yard TD to DeAndre Hopkins to cut the deficit to 29-23 with 4:48 left and the Texans got the ball back at their 20 after a three-and-out.

Watson made an incredible escape on third-and-11 and threw 22 yards to Jordan Akins for a first down at the Philadelphia 34.

On third-and-11, he hit Smith deep in the back of the end zone. Smith made an outstanding catch, and dragged his feet to stay inbounds.

Foles connected with Nelson Agholor on an 83-yard TD in the third quarter to give the Eagles a 23-16 lead. Foles changed the play at the line of scrimmage and fired a deep pass that Agholor caught in stride at the Texans 30 and ran untouched to the end zone, stopping at the 1 and falling backward in for the score.

The Texans had a first down at the Eagles 31 on the ensuing drive but Chris Long sacked Watson, forcing a fumble that was recovered by Fletcher Cox and returned to the Houston 49.

Foles then connected with Ertz on a 23-yard TD to give the Eagles a 29-16 lead. Elliott missed the extra point.

Ertz had 12 catches to break Jason Witten's record. Ertz has 113. Witten had 110 catches for the Dallas Cowboys in 2012.

Watson ran in from the 5 one play after Clowney's strip-sack and recovery, giving the Texans a 9-7 lead.

The Eagles scored a TD on their opening drive for just the fourth time this season. Darren Sproles turned a short pass from Foles on fourth-and-2 into a 37-yard TD to give Philadelphia a 7-0 lead.

INJURIES

Texans: WR Demaryius Thomas (right leg) was carted off the field in the fourth quarter. CB Kareem Jackson (knee) and CB Kayvon Webster (thigh) were injured in the first half. CB Johnathan Joseph (neck) went down in the third quarter.

Eagles: LT Jason Peters (quad) got hurt on the first possession.

UP NEXT

Texans: Host the Jacksonville Jaguars next Sunday.

Eagles: Visit the Washington Redskins (7-8) next Sunday.

---

More AP NFL: https://apnews.com/NFL and https://twitter.com/AP-NFL

Copyright 2018 by AP. Any commercial use or distribution without the express written consent of AP is strictly prohibited.