PHILADELPHIA (AP) -- After building a 27-point lead, the Philadelphia Eagles needed a defensive stand to win the game.
Nick Foles threw two touchdown passes, the defense and special teams each scored and the Eagles held on for a 34-28 victory over the St. Louis Rams on Sunday.
"We have to learn how to finish better," Foles said. "As a team, we're not there yet."
Austin Davis rallied St. Louis (1-3) from a 34-7 deficit with three straight scores, including a 5-yard pass to Brian Quick that cut it to 34-28 with 4:41 left.
The Rams had a chance for the win when they got the ball at their 7 with 1:47 left. Davis threw a 43-yard pass to Quick on first down, but Philadelphia's defense finally made a stop. Davis was under pressure when he threw an incomplete pass on fourth-and-13.
"We were rolling. I had no doubts in my mind we were going to win," Davis said of the final drive.
Davis, who began the year as the No. 3 quarterback, finished with 375 yards passing and three TDs in his first game since being elevated to starter for the rest of the season.
The Eagles (4-1) rebounded from a tough loss at San Francisco with a strong all-around performance until the offense stumbled and defense nearly collapsed in the fourth quarter. Chris Maragos returned a blocked punt for a touchdown, Cedric Thornton recovered a fumble for a score and nearly took another one the distance.
"Tough 4-1, soft 4-1, it doesn't matter," Eagles coach Chip Kelly said. "You're 4-1 and you go back to work Tuesday."
The Eagles have scored seven TDs on special teams and defense, including five in the past two games. Meanwhile, Kelly's high-flying, up-tempo offense isn't clicking the way it did last year -- but the team is winning.
"Turnovers equal victories," Thornton said. "We try to get our hands on the ball and we've been capitalizing on it."
Foles tossed a 9-yard pass to Riley Cooper with 30 seconds left in the second quarter, ending a drought of 18 drives and 97:04 without an offensive TD. He connected with Jeremy Maclin on a 24-yard pass for a 34-7 lead in the third.
On St. Louis' first play of the second half, Trent Cole sacked Davis and forced a fumble that Thornton recovered in the end zone for a 27-7 lead. Later in the third quarter, Thornton picked up a fumble after Brandon Graham stripped Zac Stacy and rumbled 40 yards before he was dragged down from behind. That set up Foles' second TD pass.
LeSean McCoy, an All-Pro last year, had 81 yards rushing. He had 39 yards on 29 carries in the previous two games.
The Rams wouldn't go down easily. Benny Cunningham had a 14-yard TD run and Davis fired a 30-yard pass to Kenny Britt to cut it to 34-21 with 9:02 left. Then, a fumble by Foles led to another TD.
But Davis couldn't complete a remarkable comeback.
"This team likes to play. They always believe they have a chance," Rams coach Jeff Fisher said.
The Eagles took a 7-0 lead when James Casey blocked a punt, Maragos scooped it up and ran 10 yards for a touchdown. It was the second straight game the Eagles blocked a punt for a score and the first time in team history they've had a TD on special teams in three consecutive games. Chris Polk returned a kickoff 102 yards in a win over Washington in Week 3.
The Eagles' first two drives stalled inside the 10. Cody Parkey kicked field goals of 26 and 27 yards.
After E.J. Gaines intercepted Foles' deep pass at the Rams 16, Davis led them on a long drive. He scrambled backward, avoided a pass rush and threw from the 25, an 8-yard TD pass to Quick in the back of the end zone to cut it to 13-7.
NOTES: Fisher, who began his NFL coaching career as an assistant under Buddy Ryan in Philadelphia in 1986, fell to 4-1 vs. the Eagles. ... The Ravens in 2002 were the last team to score a TD on a blocked punt two straight games before Eagles did it. ... Stacy left the game with a calf injury. ... Eagles LB DeMeco Ryans (right groin) and RB/KR Chris Polk (hamstring) didn't return.