Updated

The unlikely comeback began rather innocently, with a pair of hits that didn't make it out of the infield.

Then came two drives off the outfield wall, providing the Baltimore Orioles with an exclamation point on a successful homestand and a wave of momentum heading into Yankee Stadium.

Wilson Betemit hit a three-run homer in the bottom of the ninth inning after Matt Wieters doubled in two runs, and Baltimore rallied to a 5-2 victory over the Oakland Athletics on Sunday.

"We got a team where everybody pulls together," Betemit said in the jubilant Orioles clubhouse. "Everybody knows how to play, knows how to win, and that's what we do."

The victory concluded a 5-1 homestand. Next up for Baltimore: A three-game series against the Yankees, who swept Baltimore at Camden Yards earlier this month.

"It's nice to finish on that note," Wieters said. "We'll enjoy it for the rest of the day and then move on to play the Yankees."

Oakland starter Bartolo Colon took a four-hit shutout into the ninth without allowing a runner past second base.

After J.J. Hardy led off with an infield hit and Nick Markakis struck out, Adam Jones hit a chopper down the third-base line that Colon collected before throwing wildly to first. The single and error put runners at second and third and ended Colon's afternoon.

"In fairness to Bartolo, he pitched great," Oakland manager Bob Melvin said. "Even in the last inning he gives up a ground ball and then a swinging bunt. ... It certainly wasn't his fault."

Grant Balfour (0-1) entered and promptly gave up a double to left by Wieters that bounced off the wall in left-center.

"It wasn't like I left it up, but I left it up enough (for Wieters) to get a good swing on it," Balfour said.

After Chris Davis received an intentional walk, Betemit drove a 3-1 pitch to right-center that bounced off the top of the wall — a home run, according to the ground rules at Camden Yards.

"I don't know the ball is gone," Betemit said of his first career walk-off homer. "I just hit the ball, and I tried to put it in play."

Balfour, after his second blown save of the season, said, "I'm going to have my days and some days I'm not. Today is a day I have to move on from."

Colon had not given up a run on the road through three starts and 23 innings before the ninth.

Pedro Strop (3-1) got three outs for the Orioles, who moved six games over .500 (14-8) for the first time since July 20, 2005.

"It beats the alternative," said manager Buck Showalter, whose 999th career victory was one to savor. "It's like the right side of the earth. I just like seeing a lot of our guys getting a return for what they've been putting into it from a team standpoint."

Oakland was 10-0 when leading after eight innings. It was the Orioles' second win this season when trailing after eight innings, matching their total all of last season.

Baltimore starter Tommy Hunter matched Colon for five innings, allowing only one runner to pass first base, before faltering in the sixth. The right-hander gave up two runs and seven hits over seven innings.

In the sixth, after Hunter retired the first two batters, left-handed hitter Josh Reddick slapped a high fastball to left for a single and Yoenis Cespedes followed with an RBI double. That put the A's in position to go 9-0 this season when scoring first.

It didn't happen.

Seth Smith led off the seventh with his second home run, a shot to center on a 1-0 pitch. It was the eighth homer yielded by Hunter in five starts. Markakis opened the bottom half with a double but did not advance.

The Orioles got a hit in each of the first three innings, but got only one runner to second base. Oakland had two on with two outs in the third before Reddick grounded out.

Kurt Suzuki began the A's fifth inning with a drive to deep left field. Nolan Reimold extended his glove over the 7-foot wall and latched onto the ball to rob the catcher of a home run.

NOTES: Reimold doubled in the first inning to extend his career-high hitting streak to 14 games. ... Oakland SS Cliff Pennington snapped a 0-for-16 skid with a third-inning single. ... RHP Jason Hammel (3-0, 1.73) starts for Baltimore on Monday night against the Yankees. ... The A's continue their road trip in Boston on Monday. ... Baltimore has won 57 straight when allowing two or fewer runs.