PITTSBURGH (AP) — The Pittsburgh Pirates spent a good portion of the first half of the season trying — and failing — to find any sort of traction.

Once they'd figure out one problem, another would pop up. If it wasn't the bullpen, it was the mess left by outfielder Starling Marte's 80-game steroid suspension. Or the back end of the starting rotation. Or the massive funk that baffled star center fielder Andrew McCutchen.

Two hot weeks have changed the discussion dramatically.

Gregory Polanco homered, Chris Stewart added three hits and the surging Pirates completed a four-game sweep of the NL Central-leading Milwaukee Brewers with a 4-2 victory on Thursday.

The Pirates have won 11 of 13 and moved within three games of Milwaukee in a division that's tightened up since the All-Star break. The Brewers have lost five straight, cutting their lead to one game over the idle Chicago Cubs.

"When you've got guys showing up and stars showing up like they did this homestand, good things are going to happen," said McCutchen, who provided some insurance with an RBI single in the fifth off Jimmy Nelson (8-5). "When we play our best baseball, we can compete with anybody."

The Pirates focused on pressuring Milwaukee's defense during the series, forcing the issue whenever it had the chance. They scored three of their four runs by taking risks that paid off beautifully. Adam Frazier singled with two outs in the second and scored on Stewart's single to right. With the game tied at 2 in the fifth, Stewart led off with a single then moved to second on a sacrifice bunt.

The 35-year-old catcher — who spent time on the disabled list this season with hamstring issues — chugged home from second on a two-out single to right by Josh Harrison. Harrison went to second when right fielder Domingo Santana's throw missed the cutoff. Harrison then scored on a flare to right by McCutchen.

"I think we want to be in the right position to take that extra step," Stewart said. "I know there's two outs so I'm getting a couple extra steps off second base and going on the crack of the bat. We focus on those types of things."

Jameson Taillon (6-3) struck out a season-high eight in 5 1/3 innings. Felipe Rivero worked a perfect ninth for his ninth save. Pittsburgh is .500 (48-48) for the first time since April 16, two days before Marte's suspension began.

"I wouldn't say it's good to be at .500, but it's good to be playing good baseball," Stewart said. "We feel like we're doing what we thought we were capable of doing."

Taillon threw career-high 116 pitches before giving way to four relievers that kept slumping Milwaukee. Juan Nicasio worked out of a two-on, one-out jam in the eighth and Felipe Rivero worked a perfect ninth for his ninth save as the Pirates put together their first four-game home sweep since taking four straight from St. Louis in July, 2013.

The Brewers were one of the biggest surprises in baseball during their first half. They took a 5½ game lead into the All-Star break but have seen that all but erased in the span of seven days. The problem isn't so much the pitching but the offense. Milwaukee has managed just 13 runs during its five-game losing streak, tied for its longest of the season. The Brewers left nine men on and went 1 for 10 with runners in scoring position on Thursday.

"Their bullpen was really tough on us manager Craig Counsell said. "Their starters bent a couple (of) innings, but we didn't get that big inning that really kind of gave us a big lead ever."

Nelson gave up four runs on six hits, with a walk and five strikeouts and isn't overly concerned about his team's rut.

"I mean, we're still in first place," Nelson said. "You're not going to win every single game, you're not going to win every single series. But there's a lot of games left to be played and we know what we're capable of. It doesn't make us question our ability by any means."

TRAINER'S ROOM

Brewers: OF Ryan Braun was held out of the lineup for a second consecutive day as the team tries to monitor his workload while he played through a strained left calf that's bothered him all season. Braun entered as a pinch hitter in the sixth and flew out with two on and two outs. ... 2B Eric Sogard (sprained left ankle) could rejoin the team during its weekend series in Philadelphia.

UP NEXT

Brewers: RHP Matt Garza (4-4) starts for Milwaukee as it begins the next leg of a 10-game road trip on Friday against the last-place Phillies.

Pirates: Start a nine-game, 10-day western road trip in Colorado on Friday. Rookie RHP Trevor Williams (3-4) faces fellow rookie Jeff Hoffman (6-1) in the opener.