PITTSBURGH (AP) -- Rickie Weeks hit a tying two-run triple and scored the go-ahead run on Aramis Ramirez's single, helping the surging Milwaukee Brewers rally for a 9-7 victory over the Pittsburgh Pirates on Thursday.
The Brewers have won five straight, eight of nine and 15 of 19 to climb into the playoff race. They remained 2 1/2 games back of St. Louis for the second NL wild-card slot.
Milwaukee trailed 7-4 before it rallied for four runs in the eighth inning.
Carlos Gomez and Jean Segura opened the inning with consecutive singles off Chad Qualls. Norichika Aoki doubled in a run with one out and Weeks greeted Chris Resop (1-4) with a triple to the 410-foot mark in left-center.
Ryan Braun was intentionally walked before Ramirez bounced a single into center field to give Milwaukee an 8-7 lead.
Ramirez had three hits and three RBIs for the Brewers, who built an early 4-0 lead. Carlos Gomez also had three hits and Aoki had two.
The stumbling Pirates (74-75) have dropped three straight and 11 of 13 to slip under .500. They are 5 1/2 games behind the Cardinals and are in danger of a 20th straight losing season, which would extend their major North American professional sports record.
Pittsburgh star Andrew McCutchen hit a three-run drive for his 30th homer. Clint Barmes also connected, and Starling Marte and Pedro Alvarez each had two hits.
Manny Parra (2-3), the fifth of seven Brewers pitchers, tossed a scoreless inning for the win. John Axford got three outs for his 31st save in 39 chances, working around an error by rookie shortstop Jean Segura.
The Pirates scored three runs in the sixth to take a 7-4 lead. Barmes hit his eighth homer, Marte singled in a run and Travis Snider had a sacrifice fly.
Milwaukee got off to a fast start, but Pittsburgh managed to put together a quick response.
Ramirez hit a two-run homer off Wandy Rodriguez in the first, then doubled and scored in the third.
McCutchen's drive off Mike Fiers in the bottom half trimmed Milwaukee's lead to 4-3. Pinch-hitter Alex Presley then tied the game with a run-scoring fielder's choice in the fourth.
Rodriguez allowed four runs and five hits in four innings. The left-hander was 3-0 with a 1.40 ERA in his previous four starts.
Fiers gave up three runs and five hits in three innings. The rookie is 3-4 with a 6.75 ERA in his last eight starts after going 6-4 with a 1.82 ERA in his first 12.
NOTES: Brewers 1B Corey Hart played for the first time in 10 days: He had been sidelined by a torn plantar fascia in his left foot. He went 1 for 3 and was pulled after five innings to rest. ... Pirates 2B Neil Walker returned to the lineup after sitting out two of the previous three games with lower back soreness. ... Milwaukee opens a four-game series at Washington on Friday night while Pittsburgh begins a three-game series at Houston. RHP Shaun Marcum (5-4, 3.91 ERA) will pitch for the Brewers against Nationals RHP Edwin Jackson (9-10, 3.89 ERA). Pirates LHP Jeff Locke (0-1, 5.49 ERA) will look for his first major league win when he faces Astros RHP Edgar Gonzalez (2-1, 4.40 ERA).