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.
"We're doing everything right, right now," Ramirez said. "I played on a couple of really good teams in Chicago (with the Cubs) but we started off the season really well. We've kind of made a late push here. Hopefully, it's not too late."
|More on Brewers-Pirates|
|More MLB coverage|
Milwaukee had quite the closing push on Thursday. It trailed 7-4 before rallying 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.
"I was thinking extra-base hit because not only would that score a run there but it would give Rickie a chance to tie the game up in the next at-bat," Aoki said.
Which is exactly what Weeks did.
"Rickie's hit was huge," Milwaukee manager Ron Roenicke said. "That was a great at-bat, a big hit off a breaking ball."
Ramirez had three hits and three RBIs for Milwaukee, which built an early 4-0 lead. Gomez also had three hits and Aoki extended his hitting streak to 10 games.
"We did so many good things offensively," Roenicke said. "Guys are running well, they're moving runners, they're doing a lot of things to help us. When a team rolls, it's not just one or two guys that are doing it."
The stumbling Pirates (74-75) have dropped three straight and 11 of 13 to slip under .500 for the first time since May 29. 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.
The Pirates were a season-high 16 games over .500 on Aug. 8 at 63-47 but have lost 28 of 39 games since.
"I wish I had an answer for why we're struggling," Barmes said. "Everything was clicking for us for so long and it seemed like we were doing all the little things right to win games. Now it's not clicking and it just seems like nothing is going our way."
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 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.
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.
"When we pitch, we usually win ballgames," Ramirez said. "Today we didn't pitch and we scored a lot of runs. That's how good teams win ballgames, you've got to pick each other up."
- 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).