ARLINGTON, Texas -- Homecoming for Adrian Peterson and Christian Ponder went from sweet to sour at the last minute.

Tony Romo answered Peterson’s go-ahead touchdown by throwing the winning pass to Dwayne Harris with 35 seconds remaining, and the Dallas Cowboys avoided an upset with a 27-23 victory over the Minnesota Vikings on Sunday.

Romo’s 7-yard pass to Harris came after an 11-yard touchdown by Peterson that had given Minnesota a 23-20 lead. The East Texas kid raised on the Cowboys had 140 yards rushing in his first game at their $1.2 billion stadium.

Ponder threw for a touchdown and ran for another score against his hometown team, but it wasn’t enough to avoid a fourth straight loss for the Vikings (1-7).

Romo threw for 337 yards and two touchdowns as the Cowboys (5-4) bounced back from a devastating loss at Detroit by avoiding what probably would have been a more damaging defeat.

Romo’s first attempt to answer Peterson’s go-ahead score was intercepted on a great play along the sideline by A.J. Jefferson — and was a reminder of the late pick he threw in Dallas’ only home loss this year.

Dallas didn’t get another shot after that play, with Peyton Manning and the Denver Broncos running out the clock and winning 51-48 on a field goal on the final play.

But the Vikings couldn’t convert this late Romo mistake into points and gave him the ball back at the Dallas 10 with 2:44 remaining.

Dez Bryant had a 34-yard catch that put Dallas in position for at least a tying field goal, which was possible because Blair Walsh missed wide right on the extra point after Peterson’s touchdown. But Romo kept pushing.

He threw 9 yards to Cole Beasley and 5 to Jason Witten, who led Dallas with eight catches for 102 yards. On the next play, Romo found Harris cutting between defenders in the middle of the field, and Harris dived over the goal line.

Peterson got Minnesota’s go-ahead drive earlier in the quarter going with a 52-yard run, then went the final 11 on fourth-and-1. He easily got the first down and carried safety Jeff Heath the last few yards, with Heath trying to strip the ball as Peterson crossed the goal line.

“I don’t really care about the yards,” said Peterson, who had 25 carries and another 37 yards receiving. “I want to get some Ws. I don’t want to rush for 2,000 yards and be sitting at home watching others play.”

After there was one touchdown between the teams in the first half, there were three in the first 7 minutes of the third quarter.

Romo had consecutive 26-yard completions to Witten, the second for a touchdown and a 13-10 lead.

A week after Cordarrelle Patterson set an NFL record with a 109-yard kickoff return for a touchdown, he fumbled a short kickoff out of bounds at the Minnesota 5.

On the next play, George Selvie knocked the ball out of Ponder’s hand in the end zone, and the Cowboys ended up with touchdowns just 10 seconds apart on the fumble recovery by Nick Hayden.

Ponder had an answer, though, finding Jennings for 27 yards on third-and-4 before going to Kyle Rudolph, who bounced off Barry Church at the 6 and finished off a 31-yard scoring catch to get the Vikings to 20-17.

“I need to be out there playing,” said Ponder, who was 25 of 37 after being named starter on Friday, and with Josh Freeman inactive because of a concussion. “For myself and the leaders on this team, we need to get this turned around and get out there and win.”

Ponder led a pair of 11-play scoring drives in the first half, the second one ending on his 6-yard scramble for a 10-6 lead late in the second quarter.

The Cowboys were in position to extend their 20-17 lead when Bryant took his team out of field goal range with unsportsmanlike conduct for taking off his helmet and arguing with officials as a pass interference penalty against him was about to be announced.

Bryant, who made headlines last week with a pair of sideline outbursts in a loss at Detroit, later dropped an easy first-down catch on second-and-18 on a drive that ended with a punt.

Copyright 2013 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.

More From KSOO-AM / ESPN Sioux Falls