CHICAGO — The Los Angeles Dodgers spoiled Jon Lester’s return to the Cubs’ rotation by scoring on an error and a sacrifice fly, beating Chicago 2-1 on Thursday to avoid a three-game sweep.

Lester (1-1), who spent 16 days on the injured list with a left hamstring strain, allowed one run on four hits in five innings.

Cody Bellinger drove in the Dodgers’ second run with a sacrifice fly off Kyle Ryan in the eighth after Los Angeles loaded the bases with two walks and a hit batter. It was Bellinger’s 31st RBI of the season, tying Milwaukee’s Christian Yelich for the most in the majors. Bellinger went 1 for 2, raising his major league-leading batting average to .426.

Pedro Baez (2-1) struck out three in 1 1/3 innings for the win. Kenley Jansen allowed Albert Almora Jr.’s homer in the ninth but got the final three outs for his eighth save.

DIAMONDBACKS 5, PIRATES 0: Zack Greinke and two Arizona relievers allowed five hits in a victory at Pittsburgh that secured a four-game sweep.

The shutout was the second of the season for the Diamondbacks, who improved to 15-11 and moved into a tie for first place in the NL West. It was Arizona’s second consecutive four-game sweep in Pittsburgh and 10th straight win overall at PNC Park.

Greinke (4-1) was deceptive, not overpowering. Despite a fastball that averaged around 90 mph, he got 17 of them to go for called strikes. Greinke struck out seven in seven innings and gave up just two hits.

NOTES

YANKEES: Clint Frazier became New York’s 15th player to go on the injured list, sidelined because of a sprained left ankle, and the Yankees acquired Cameron Maybin from the Indians for $25,000 to gain outfield depth.

Frazier, a 24-year-old outfielder, is hitting .324 with six homers and 17 RBI. He was placed on the 10-day injured list Thursday. He was hurt Monday night sliding into second base on a pickoff attempt when he became entangled with Angels shortstop Andrelton Simmons in the 12th inning. Frazier remained in the game and finished New York’s 14-inning win.

The ankle swelled, and he didn’t play Tuesday or Wednesday, when he had an MRI.

Maybin was hitting .216 (11 for 51) with three doubles and five RBI in 14 games with Cleveland’s Triple-A Columbus farm team. The 32-year-old hit .249 with four homers, 28 RBIs and 10 steals in 129 games and 342 at-bats last year for Miami and Seattle.

METS: Right-hander Jacob Rhame was suspended for two games for sailing two fastballs over the head of Rhys Hoskins during a tense series with the Phillies.

The commissioner’s office also fined Rhame for what it said were intentional near-beanings.

The suspension is scheduled to begin Friday, when the Mets host the Milwaukee Brewers, unless Rhame appeals.

CUBS: Reliever Pedro Strop made a quick decision to help his team secure a win over the Dodgers before completing the paperwork about his stolen car.

The 33-year-old right-hander was talking to police in the Cubs clubhouse late Wednesday about his stolen Genesis when the score became tied. Cubs spokesman Julian Green said that’s when Strop told police, “I gotta get out of here, I gotta pitch tonight.”

Strop later earned the save in the Cubs’ 7-6 win.