Brady threw an 8-yard scoring pass to Aaron Hernandez with 22 seconds left and the Patriots' top-ranked offense overcame the Cowboys' stingy defense.
Dan Bailey's 26-yard field goal had broken a 13-13 tie with 5:13 left. Each team ran one series before the Patriots got the ball after a punt with 2:30 remaining. Brady then completed eight of nine passes for 78 yards on an 80-play drive capped by his pass to Hernandez in the middle of the end zone.
New England (5-1) won despite its first two lost fumbles of the season and Brady's two interceptions. He 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.
Until the final drive, Cowboys defensive coordinator Rob Ryan was headed for his second straight strong game against the Patriots.
He held that job with Cleveland when the Browns beat the Patriots 34-14 last Nov. 7. Since then, the Patriots had scored at least 30 points in 13 consecutive games. That streak ended Sunday, but New England still won.
The regular-season win was Brady's 20th straight at home and the Patriots 31st in a row at Gillette Stadium.
They took a 3-0 lead on their first possession on a 31-yard field goal by Stephen Gostkowski. It began when Kyle Arrington intercepted a pass that Dez Bryant failed to reach for on a medium-range slant pattern.
New England turned the ball over again on the kickoff after the field goal when Gerald Sensabaugh recovered a fumble by Matthew Slater, the first fumble lost by the Patriots this season. 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 Wes 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.
Dallas cut the lead to 13-10 at halftime, marching 93 yards on 11 plays to score on Romo's 1-yard touchdown pass to Witten, the star tight end's first catch of the game, with 33 seconds left.
The Cowboys tied it on Bailey's 22-yard field goal with 5:50 remaining in the third quarter.