Casey McGehee came up big again for Miami, drawing a bases-loaded walk in the ninth inning to tie the game and give him 40 RBIs -- tops among National League third basemen.
McGehee added a one-out double in the 12th inning, but was stranded on a night the Marlins showed resiliency but ended up disappointed.
"If we could have pulled that out, that would have been big," McGehee said. "But at the same time, we can't hold our head down. We've got to come back tomorrow and try to get back after them. That's the way it goes sometimes."
Giancarlo Stanton blasted his 18th homer of the season, a shot to right-center in the third inning off Jeff Locke, who impressed for Pittsburgh, throwing a career-high eighth innings.
For the second straight Friday, the Marlins mounted heroic efforts in the ninth to force extra innings. Reed Johnson had two-run hits in the ninth in both games.
On June 6 at Wrigley Field, Miami also went to 13 innings before losing 5-3 on Anthony Rizzo's two-run walk-off homer.
The 13 innings on Friday matched the season high, and the four-hour, 26-minute game vs. Pittsburgh was a season high for Miami.
"We had a chance to win it, after really the game that we played, which was sloppy," manager Mike Redmond said. "To think we still had a chance to win it, and win it again in extra innings. ... That just shows the character of this ballclub. After a long fight like that, we're frustrated we weren't able to pick up that win."
The 13th opened on Clint Barmes' single to left, and he was moved to second on reliever Jeanmar Gomez's sacrifice bunt. On a 2-2 pitch, Polanco belted his first big league homer.
"It [stinks]," Dunn said. "One bad pitch. Hung a slider. The team busted its butt to get it back to 6-6. They played their butts off and I blew it. I hung a slider, he hit it."
Miami fell to 3-5 in extra innings, and Polanco reinforced why he is so touted.
"It's crazy how games get played out," Pirates manager Clint Hurdle said. "If games get played out that way, then that happens."
Marlins pitchers combined for 16 strikeouts, which tied a season high. They fanned 16 at the Cubs, also in 13 innings, on June 6.
Gomez worked four scoreless frames for the Pirates.
Miami trailed by four entering the ninth inning, yet behind a franchise-record-tying six walks, pulled even to force extra innings. Previously, the Marlins walked six times in the ninth inning at the Cubs on July 14, 2011.
Pirates reliever Justin Wilson got the ninth going with a leadoff walk to Marcell Ozuna. With one out, the lefty walked Adeiny Hechavarria, creating a save situation for Jason Grilli. But Grilli threw 27 total pitches and walked three. Johnson's two-run single was the lone hit in the inning. With runners on the corners, Giancarlo Stanton, who homered in the third inning, was intentionally walked.
Mark Melancon entered, and after getting ahead of McGehee 0-2 in the count, walked the Miami cleanup hitter, tying the game. Ozuna, batting for the second time in the inning, struck out.
The Pirates built a big lead behind the power of their outfield trio of Polanco, Starling Marte and Andrew McCutchen, who combined for 11 hits, six RBIs and six runs.
"Their top of the order did some damage off us tonight," Redmond said. "We definitely have got to do a better job pitching to these guys and keeping them off the bases. We weren't able to do that tonight. We need to do that to win a couple of these games."
Marte belted a two-run homer and had four hits. McCutchen added two hits and an RBI. Ike Davis added a two-run double.
The Pirates collected six runs off Nathan Eovaldi, who worked 4 2/3 innings and allowed 10 hits. Polanco, Marte and McCutchen were 7-for-9 off the Miami right-hander. Marte homered on the sixth pitch of the night.
"I think I gave up six hits when I was ahead in the count," Eovaldi said. "I just wasn't putting them away. My fastball command wasn't really there. My slider was flat tonight. They hit the ball well. They capitalized on my mistakes."
For Eovaldi, this is a busy time. His wife is expecting their first child any day. But the right-hander downplayed his family situation.
"It's really not on my mind," he said. "It's just coming out here competing tonight and giving the team the best chance to win."