For the better part of 2 1/2 quarters Sunday, Joe Flacco spent nearly as much time on the ground as he did upright, the offense struggled to finish off drives, and the Ravens couldn't get anything going in the running game.

When Houston Texans quarterback Matt Schaub found Jacoby Jones in the end zone on a 32-yard touchdown pass about midway through the third quarter, the Ravens found themselves behind in a game that they seemingly had in control.

But in a dominating final 20 minutes, the Ravens, relying on some long completions from Flacco and a suffocating defense, scored the game's final 16 points to pull away from the Houston Texans and post a 29-14 victory in front of an announced 71,154 at M&T Bank Stadium.

"It was really encouraging to see the way we responded in a tight game in the fourth quarter," Ravens coach John Harbaugh said. "To have to come out and really win the fourth quarter in that kind of fashion is a huge statement. It seemed like we had the ball most of the fourth quarter, so that's how you do that."

Flacco threw for 305 yards and scored a rushing touchdown, Billy Cundiff tied a team record with five field goals, running back Ray Rice had 161 total yards and wide receiver Anquan Boldin had eight catches for 132 yards.

Unlike last season, when they blew a three-touchdown third quarter lead before beating the Texans on Josh Wilson's interception return for a touchdown, the Ravens took over the game in the second half, out-gaining Houston 269 yards to 151, dominating the time of possession and scoring on four of five drives before finally taking a knee.

Ricky Williams' four-yard touchdown run -- his first as a Raven -- with just over four minutes to play all but sealed it as the Ravens improved to 4-1 overall heading into next Monday's game against the 1-5 Jacksonville Jaguars, and 5-0 all-time against the Texans (3-3).

"You look everybody in the eye at halftime and you say, 'Let's go. Let's go do this,'" Flacco said. "We had moved the ball on them. We had to stop hurting ourselves. That's what makes it so good to win this football game. We were able to push through and really have a great second half."

There were some tenuous moments, and the capacity crowd went silent when Jones beat safety Ed Reed and Schaub found him to give the Texans a 14-13 lead with 8:46 remaining in the third quarter.

But two long Flacco completions to rookie Torrey Smith -- a 19-yarder on 3rd-and-12 from the Ravens' 17, and then a 51-yarder over the head of cornerback Kareem Jackson -- set up Cundiff's 25-yard field goal that gave the home team a 16-14 lead.

On the Ravens' next drive, Flacco, before getting slammed to the turf, hit Boldin across the field for 56 yards. That set up a 33-yard field goal by Cundiff, who was perfect in his five attempts.

"We felt like we were able to move the ball up and down the field," said Boldin. "We had miscues here and there, but for the most part, we felt like we were able to move the ball when we wanted to."

Leading 19-14, the Ravens defense did the rest. Former Texan Bernard Pollard made a great play to break up a pass intended for Arian Foster on 3rd-and-9. A sack by Pernell McPhee on 3rd-and-3 ended the Texans next drive and forced a punt, and then the Ravens stopped Houston on fourth down in its final two possessions.

Overall, Schaub, whose top target, Andre Johnson, missed the game with a hamstring injury, went just 21-for-37 for 220 yards and was sacked four times. Foster, last year's rushing champ, finished with 49 total yards on the ground on 15 carries though he did catch six passes for 52 yards.

It was quite a reversal from last year when the Texans gouged the Ravens for 489 total yards and 28 first downs. They had 293 yards and 18 first downs today, and got their only other touchdown when left guard Wade Smith recovered Ben Tate's fumble in the end zone.

While the defense was its stellar self aside from the long touchdown pass to Jones -- "It was just bad judgment on my part," Reed said of the play -- and early struggles on third down, the offense continued to battle inconsistency.

Looking sharp after the bye week, the Ravens went 97 yards in 16 plays on their first possession, ending in Flacco's 1-yard plunge into the end zone, the first first-quarter touchdown the Texans have given up all season. Flacco went 7-of-8 on the drive for 82 yards, and the Ravens also benefited from two personal foul penalties on Houston defensive end Antonio Smith.

But instead of setting the tone for a huge offensive day, the drive only added to the quarter and a half of offensive frustration that followed. The next three drives ended in a punt, a Flacco fumble that set up the Texans touchdown, a 43-yard Cundiff field goal and then a Flacco interception on a play where tight end Ed Dickson was wide open down the field.

Several plays during that span ended with Flacco laying on the turf as the Texans defense, even without Mario Williams, generated a consistent pass rush.

"My speech at halftime was simple: 'I don't care whether we run or pass it, we need to execute,'" said Rice. "Today was the day that it didn't look pretty at first, but in the second half, we got it all together. Joe Flacco, making the throws that he made, even under pressure, proved that he's an elite quarterback."

The Ravens also made some minor adjustments, opting to run the ball more inside. That resulted in 91 rushing yards in the second half after they accumulated just 22 in the first half.

But as Texans coach Gary Kubiak noted, by far the biggest plays were when Flacco had time to look down field and find open receivers. The 56-yarder to Boldin may have been Flacco's best throw, and he even admitted that he didn't think he had put enough air under the ball until he saw otherwise on the stadium JumboTron.

"I saw nerves," Harbaugh said when asked about some of Flacco's second-half throws. "I think that's an old-fashioned word for poised. I saw nerves of steel. When you have a team that knows how to win -- and I think our team knows how to win -- they find a way to win a really tough game against a good team."