ANAHEIM, Calif. -- It wasn't the way Abner Doubleday drew it up, but for the Pittsburgh Pirates, it didn't matter.
The Pirates and Los Angeles Angels played sloppy baseball for nearly four hours, but it was the Pirates who came away with a 10-9 victory in 10 innings on Sunday at Angel Stadium.
The Pirates scored three runs in the ninth to tie the game, four in the 10th to take a seemingly comfortable lead, then hung on after the Angels scored three in the bottom of the 10th and stranded the potential winning run on second base.
The victory gave the Pirates a three-game sweep of the series, while the Angels finished their longest homestand of the season at 5-5.
"It's been a common theme all year," said Pirates catcher Russell Martin, who hit a pinch RBI double in the ninth and an RBI single in the 10th.
"We go out there and battle all the way to the end. That's the beautiful thing about baseball, time never runs out. You got to make 27 outs. We just fought. It was a collective effort from everyone in the lineup and people coming off the bench.
"Normally our theme is pitching well and playing good defense, and today our offense took advantage of their mistakes."
And there were plenty of mistakes, by both teams. The Pirates made three errors and the Angels made two, as well as a couple of plays that were generously ruled hits.
"We had the door cracked open for us a couple times from their miscues and we gave some back to them," Angels manager Mike Scioscia said.
"Obviously we didn't play a perfect game on the defensive side, but we did enough things well on the field to get the game set up the way we needed. Unfortunately we couldn't get it done in the end."
The Angels set it up by taking a 6-3 lead into the ninth inning. Starter Joe Blanton pitched well, going 7 1/3 innings and giving up three runs (one earned) and six hits while striking out six and walking none.
Blanton retired the final 14 batters he faced before handing the ball to the bullpen with one out in the eighth.
Scott Downs got the final two outs in the eighth before turning it over to Ernest Frieri for the ninth with a 6-3 lead. Frieri began the day having retired 22 consecutive batters, but walked Neil Walker to begin the inning.
Frieri didn't make it out of the inning, giving up three runs on three hits and the one walk.
Andrew McCutchen, getting the day off before pinch hitting in the ninth, grounded into a fielder's choice to drive in one run. Martin followed with his pinch RBI double, and Sterling Marte tied the game with a two-out RBI single.
In the 10th, the Pirates put up four runs, fueled by J.B. Shuck's error in left field.
The Pirates had the bases loaded and one out against Angels reliever Kevin Jepsen (0-2) when Travis Snider lined a single to left. The ball scooted past Shuck for an error and went to the left field wall, allowing all three runners to score.
Pittsburgh added another run in the inning on Martin's RBI single, and it turned out to be the difference.
The Angels made things interesting with three runs in the bottom of the 10th, but Jason Grilli struck out Mike Trout to finish it with runners on second and third.
"These guys that struggled today (Frieri and Jepsen) have done well for us and that's important to remember moving forward," Scioscia said. "This is one that got away from us. What's frustrating is we did so many good things on that field.
"Our pitching staff did a good job getting us there, but at the end we just couldn't close that door. You have to be a good enough team to absorb non-performance, and when it comes from your closer, it's going to be magnified."
It was Frieri's second blown save of the season in 19 opportunities, the first one coming April 29 in Oakland.
Pirates starter Charlie Morton couldn't survive his defense, giving up six runs (three earned) and four hits in 5 2/3 innings. He walked five and struck out five.
Pedro Alvarez hit his 19th home run of the season for the Pirates, and has hit home runs in four consecutive games.
Mark Melancon (2-1) earned the victory over Jepsen (0-2).
NOTES: Pirates C Tony Sanchez made his major league debut in the designated hitter spot and doubled in his first at-bat. The ball stuck in the right-field wall, which holds the electronic scoreboard, and was ruled a ground-rule double. After the inning, a stadium worker used a ladder to retrieve the ball, which was thrown into the Pirates dugout for Sanchez's keepsake. ... Pirates CF Andrew McCutchen was not in the starting lineup. It was only a day off for McCutchen, who was replaced in center field by Sterling Marte. McCutchen entered the game as a pinch hitter in the ninth and went 1-for-2 with a run scored and an RBI ... Angels CF Peter Bourjos left the game after the third inning because of an injury to his left thumb. Bourjos hurt the thumb when sliding into Pirates SS Jordy Mercer trying to break up a potential double play in the second inning. He had X-rays taken, but the results were not immediately available. ... Angels RHP Ryan Madson will go to extended spring training in Arizona Monday to begin throwing again. Madson has endured numerous setbacks in his recovering from Tommy John surgery in April of 2012.