MILWAUKEE - In a season defined so far by their inconsistent starting pitching, the Milwaukee Brewers got a rare gem Tuesday night from Chase Anderson.

The right-hander took a no-hitter into the eighth inning and a shutout two outs into the ninth against the major-league-leading Chicago Cubs before giving up consecutive home runs that ended his outing.

But Jeremy Jeffress picked Anderson up from there, striking out Anthony Rizzo to preserve a 4-2 Brewers victory in front of a crowd of 24,361.

Anderson (2-3) lasted a career-best 8 2/3 innings, falling just short of tossing Milwaukee's first complete game since Taylor Jungmann last July 11 on the road against the Los Angeles Dodgers. He allowed three hits, two runs (earned) and a walk while striking out a season-high six.

The victory snapped a seven-game Cubs winning streak at Miller Park.

Pitching against the Cubs for the first time in his career, Anderson got some major help from his defense in the first three innings.

In the first, Kirk Nieuwenhuis made a leaping grab of a Kris Bryant drive at the wall in center, robbing the Cubs' third baseman of at least extra bases. Aaron Hill made a great diving stab to his left to take a base hit away from Rizzo on the shift in the second; and in the third, shortstop Jonathan Villar gloved a hot shot that caromed off Hill's glove at third base to throw out Javier Baez.

The Brewers broke a scoreless tie in the fourth when Jonathan Lucroy homered to left — his third in as many games. It was the first homer allowed by Cubs starter Kyle Hendricks (2-3) in seven career starts against Milwaukee.

Anderson rolled through the fourth and fifth innings before needing 20 pitches to finish the sixth. His bid for a perfect game was lost when he got ahead of Miguel Montero, 0-2, before walking him, but Anderson recovered by striking out Hendricks and Dexter Fowler.

Milwaukee chased Hendricks from the game with three runs in the bottom of the frame. Ryan Braun, playing for the first time since Friday, singled to drive in Villar and then two batters later Chris Carter's two-RBI double to right-center made it 4-0.

That was all for Hendricks, who came into the night 4-1 with a 1.49 earned-run average against the Brewers.

Anderson pitched a 1-2-3 seventh, striking out Rizzo looking to end it, to take his no-hitter into the eighth. It wasn't long before it was ended, though, as Ben Zobrist hammered a first-pitch fastball for leadoff double to center.

Anderson recovered with three quick outs, and after Trevor Cahill set the Brewers down in order in the eighth, Anderson headed back to the mound for the ninth. Anderson's previous career high for innings was eight, set last May 20 in a victory in Miami.

Anderson recorded the first two outs in the ninth and got ahead of Jason Heyward, 0-2, before the rightfielder slammed a homer over the wall in right-center to break up the shutout.

Two pitches later Bryant sent a fastball over the wall in left, and Anderson's night was done at 110 pitches as manager Craig Counsell called on Jeffress, who struck out Rizzo on four pitches to save his 10th game in as many opportunities.