PITTSBURGH – As he dug in for his at-bat in the 13th inning Wednesday, Joe Mauer was looking to drive the ball to the opposite field against Pirates lefthander Antonio Bastardo.

"But he made a mistake up and in," Mauer said, "and I was able to react to it."

The result hadn't been seen off his bat in quite a while. Mauer cleared the wall in right field with what turned out to be the winning blow in the Twins' 4-3 victory over Pittsburgh.

For Mauer, the career-longest power drought is over. He went deep for the first time since Aug. 17 of last year — 76 games and 322 plate appearances ago.

The last time Mauer homered, David Letterman had a show.

Glen Perkins got through the bottom of the inning for his 15th save and 15th in a row, the longest streak of his career.

Mauer's blast turned the tables on a game in which the Twins lost a 3-1 lead when their emerging relievers, lefthander Aaron Thompson and righthander Blaine Boyer, gave up run-scoring hits. Thompson gave up a single to Jose Tabata in the seventh and Boyer gave up a home run to Andrew McCutchen in the eighth. The Twins were 20-1 when leading after seven innings at the time.

The Twins had to turn to Rule 5 draft pick J.R. Graham because of in-game attrition, and the rookie responded with three shutout innings.

All the Twins needed was a run, but the offense went in the tank after scoring three runs in the first inning.

"You just try to keep the energy up," Twins manager Paul Molitor said. "It gets tough. Everyone knows it's a travel night. The professional guys show up. You keep trying to find a way to fight."

The Twins improved to 3-1 in extra-inning games and head into a weekend series in Chicago having won four of their past five games. They are a season-high six games over .500, at 23-17.

"We're headed in the right direction," said righthander Mike Pelfrey, who held Pittsburgh to one run over six innings. "Hopefully things stay on the upswing."

Pelfrey was given a 3-0 lead in the first, and it looked like it would be enough.

Danny Santana led off with a double, Mauer singled him to third and Trevor Plouffe walked to load the bases with one out. Meanwhile, the Pirates bench was giving it to plate umpire Jeff Kellogg over his ball-and-strike calls.

Torii Hunter doubled off the right-field wall to clear the bases and give the Twins an early 3-0 lead. Locke needed 38 pitches to get through the first inning, but the Twins didn't build off it. Locke settled down to pitch six innings, giving up three runs on seven hits and two walks. He even retired the final seven Twins he faced.

The bullpen has had few shaky moments, but Ryan Pressly issued two one-out walks in the seventh, and by the time the inning was over — Molitor needed three pitchers to get three outs — Pittsburgh had cut the lead to a run.

Boyer brought a 17⅔-inning scoreless streak into his outing, but that abruptly ended when McCutchen homered. But the Twins shut down Pittsburgh the rest of the way and were rewarded for it in the 13th.

"It was a grind," Mauer said.

Just like the wait for him to hit his first home run of the season.

"Much has been said about it," Molitor said. "I hope his timing on his next one is as good as it was tonight."