BALTIMORE – The Twins on Sunday swapped roles, made their own breaks and accepted gifts. And they were rewarded with a remarkable victory to end an improbable week.

Contributions came from everywhere as they rallied to beat the Orioles 4-3 in 12 innings Sunday. The Twins entered Oriole Park at Camden Yards on Thursday with a three-game losing streak and exited on Sunday with a four-game sweep, their latest statement that they know how to rebound.

"Crazy game," shortstop Eduardo Escobar said. "But you play hard. It's competition, and winning is much fun."

The Twins blew out the Orioles 15-2 on Thursday, then won the next three by a run. The Orioles entered the series 51-1 in games they led after seven innings and lost twice in that scenario. Baltimore is one of the most fundamentally sound teams in the game, but the Orioles threw to the wrong base Friday, failed to advance a base in a key situation Saturday and handed Sunday's game to the Twins with two 12th-inning errors. The Twins jumped over Baltimore in the wild-card standings and are tied with the Angels, 1 ½ games out of the final playoff spot.

It's the Twins' first four-game sweep here since August 2007. The four-game road win streak ties for their longest of the season. And Tommy Milone became the first Twins pitcher to have a win as a starter and a save in the same season since Francisco Liriano in 2006.

Escobar reached second base in the 12th when Manny Machado, an All-Star third baseman playing his first inning at shortstop in his four major league seasons, booted his grounder. With two outs, Shane Robinson sent a grounder to new third baseman Jimmy Paredes, who bungled the ball. It deflected toward deep short and past Machado, and Escobar scored before Machado could throw home.

"I see the ball and I run hard," Escobar said. "Keep going, keep going."

Paredes had entered as a pinch runner in the 11th inning for gimpy shortstop J.J. Hardy, who said after the game he was headed to the disabled list. With Paredes at third and Machado at short, the Twins were handed a go-ahead run.

Closer Glen Perkins wasn't supposed to pitch Sunday but was pressed into service in the 11th inning, which he ended by striking out Adam Jones with runners on first and second. Now the Twins needed someone to close. Enter Milone, who was between starts and was supposed to throw a bullpen session. He pushed that session back to Tuesday and was called upon to close this one.

A flyout to center and two strikeouts later, the game was over.

"I was trying to stay within myself," Milone said. "If I try to throw any harder, my ball might leak over the plate."

The Twins tied the score during an action-packed ninth inning that included manager Paul Molitor's third ejection. Brian Dozier legged out an infield hit, diving to beat closer Zach Britton to the bag. Joe Mauer grounded out, with Dozier moving to second.

Miguel Sano then tried to check his swing with two strikes, but first base umpire Gabe Morales signaled that he went around. Molitor exploded and was ejected. He walked toward first but was stopped by plate umpire Chris Conroy, who didn't see Morales' ejection and tossed Molitor again.

"I don't like losing emotion and control very often," said Molitor, who disagreed with Morales earlier in the game, "but I was pretty hot at the moment. I got what I deserved."

Molitor still was in the tunnel leading from the dugout when Trevor Plouffe singled to left with two out, scoring Dozier with the tying run. The Twins hadn't scored since the first inning, when Sano hit his fourth home run of the week, a two-run shot to left.

Who knew then how this one would turn out?

"Give everybody credit," Molitor said. "A lot of guys manned up."