FOXBOROUGH, Mass. – Down three points. Barely two minutes left. One thought on Tom Brady’s mind.

“You can’t not get the ball in the end zone,” the master of late comebacks said.

That’s where he got it, throwing an 8-yard touchdown pass to Aaron Hernandez with 22 seconds left and giving the New England Patriots a 20-16 win over the Dallas Cowboys on Sunday.

“He’s probably one of the toughest competitors I’ve ever seen, especially from a quarterback standpoint,” Patriots defensive tackle Vince Wilfork said. “There was plenty of time for our offense.

“When it mattered the most, they came up with what we needed.”

It was the 32nd successful comeback of Brady’s career in games the Patriots trailed or were tied in the fourth quarter. And it came against a solid defense — ranked fourth in the NFL — that had allowed just one touchdown on the Patriots first nine possessions.

“When you’re playing against a quarterback like Tom Brady, he’s going to go down as one of the all-time greats,” Cowboys Coach Jason Garrett said. “So you have to try to make it hard on him.”

Dallas, coming off a bye week, did that for most of the day, sacking him three times and intercepting two passes. But on the final 80-yard drive that started with 2:31 left, Brady completed eight of nine passes for 78 yards.

“We prepare hard for that situation every week and when it came up this week, it’s good to get the ball in the end zone,” Brady said. “I’d prefer to be up four touchdowns with two minutes left, but it just wasn’t the case.”

New England (5-1) won despite its first two lost fumbles of the season. Brady finished the game 27 of 41 for 289 yards with two touchdowns.

Dallas (2-3) ended a five-game road winning streak after a bye despite coming back from a 13-3 deficit midway through the second quarter.

Tony Romo was 27 of 41 for 317 yards, one touchdown and one interception in his first game since a 34-30 loss to the Detroit Lions in which the Cowboys squandered a 24-point, third-quarter lead and Romo threw two interceptions that were returned for touchdowns.

The Cowboys have lost two games by four points and one by three.

“This team is continuing to grow and get better,” Romo said. “We just need to finish a game like today and we will I think.”

Dan Bailey’s 26-yard field goal, his third of the game, had broken a 13-13 tie with 5:13 left. After the Patriots punted, the Cowboys were content to run the ball — three rushes for 5 yards, plus a 5-yard penalty — and punted right back.

“You have to run the ball in that situation because of the time situation,” said Garrett, who trusted his defense to keep stopping the Patriots if it had to. “It’s one of the best offenses in the league. You’re challenging your defense, no doubt about it.”

Wes Welker, who entered the game as the NFL leader with 45 catches and 740 yards receiving, was held to six for 45, but three of those catches, covering 21 yards, came in the go-ahead drive. The last one covered 6 yards over the middle, putting the ball at the 8.

Then Brady found Hernandez in one-on-one coverage.

“I had an in route and (Rob) Gronkowski had an out route and he’s a great player so he drew the safety’s attention,” Hernandez said. “I came around and Tom made a great throw and I just had to make the catch.”

The regular-season win was the Patriots’ 20th straight at home and Brady’s 31st in a row at Gillette Stadium.

“When it comes to crunch time, he is at his best,” Cowboys linebacker Keith Brooking said.

The Patriots took a 3-0 lead on their first possession on a 31-yard field goal by Stephen Gostkowski. The Cowboys tied it on Bailey’s 48-yard field goal after Terence Newman intercepted a pass that was tipped by defensive end Kenyon Coleman.

New England turned the ball over again on the kickoff after the field goal when Gerald Sensabaugh recovered a fumble by Matthew Slater. But Dallas gave the ball right back five plays later when Tashard Choice fumbled and Gerard Warren recovered.

The Patriots capitalized with a 26-yard field goal by Gostkowski with 12:07 left in the half for a 6-3 lead.

They made it 13-3 on their next possession on a 5-yard touchdown pass from Brady to Welker. Officials ruled initially that Welker had gone out of bounds as he reached the ball out toward the goal line but that was overturned on video review.