Looking to complete a rare sweep against the Chicago Cubs, the Pittsburgh Pirates built an early five-run lead Sunday afternoon at Wrigley Field.

They couldn’t make their good fortune last.

The Cubs rallied for two runs in the eighth and one in the ninth for a 7-6 come-from-behind victory to salvage the final game of the series against the first-place Pirates.

Carson Kelly’s bases-loaded, one-out single off reliever Jose Urquidy snapped a 6-6 tie for the Cubs, who rallied from 5-0 and 6-2 deficits.

“If we continue this way, win two of three the rest of the year, we’re going to be in a good spot,” said second baseman Brandon Lowe on the SportsNet Pittsburgh post-game show after hitting a grand slam and a solo homer. “It’s tough because there are games where the other team wins and games that you lose. I think everybody in here feels that way, that we lost this one.”

The Pirates lost for just the third time in the past 11 games. They were four outs away from securing their first sweep of the Cubs since September 2019 and their first at Wrigley Field since April 2017.

The Pirates also were denied a chance of moving five games over .500 for the first time since April 2024.

“It would have been nice to get this one, too, but taking two of three from the Cubs in Wrigley, I’m really proud of the way we played,” manager Don Kelly said.

Pinch-hitter Michael Conforto opened the ninth with a double to right field against Urquidy. Pinch-runner Scott Kingery remained stationed at second when Alex Bregman singled to the hole at short.

Mt. Lebanon’s Ian Happ hit into a fielder’s choice, which put the winning run on third. base. Seiya Suzuki walked after falling behind 0-2.

Carson Kelly hit a fly ball to the warning track in right-center that landed safely for the winning hit.

Trailing 6-4, the Cubs tied the score in the eighth with a pair of two-out runs against Justin Lawrence.

With runners on first and second, pinch-hitter Michael Busch ended an 0-for-30 slump when he hit a flare to left-center field for a single that scored Suzuki. Bryan Reynolds’ throw to second was wild, and Dansby Swanson came around from first to score the tying run.

Lawrence was hurt by the two walks he issued in the inning.

“There are some things we need to clean up defensively there, and walks continue to bite us,” Kelly said.

Lawrence has allowed runs in each of his past four appearances, giving up six runs, seven hits and three walks in 3 2/3 innings.

“He’s going to get some big outs for us this year,” Kelly said. “He’s not feeling it right now.”

Lowe went 2 for 5 with two homers and five RBIs. But Lowe was called out on a checked swing to end the ninth with the go-ahead run on third base.

Oneil Cruz also homered for the Pirates.

Pirates starter Bubba Chandler worked into the sixth for the first time this season and allowed three runs in 5 1/3 innings.

The Pirates took the lead on the third pitch of the game. With the wind blowing out, Cruz homered to right-center against former Pirates pitcher Jameson Taillon, extending his hitting streak to 11 games, tying a career high.

The homer was the fifth of the season for Cruz and a sign of things to come for balls launched in the air.

Lowe hit his sixth career grand slam in the third inning for a 5-0 advantage. It came after Cruz was called out on strikes after the Cubs challenged a ball four call. Lowe sent a 1-0 pitch into the right-field seats. It was his fourth home run of the season.

Lowe added his fifth in his next at-bat, launching a homer deep to right field off Taillon, a 444-foot shot that didn’t require the help of the wind to clear the fence.

In between, the Cubs hit a pair of solo homers against Chandler, both coming in the third inning.

Entering the game, Pirates starters had yielded just one home run this season. Chander gave up the pair in a four-batter sequence, with Swanson and Moises Ballesteros taking him deep.

The Cubs pulled within 6-3 in the fifth on Bregman’s sacrifice fly.

Chandler finished the inning, then he struck out Suzuki to open the sixth before being lifted with his pitch count at 91. That he threw 64 of those pitches for strikes was a testament to his improved command.

Entering the game, Chandler had allowed 10 walks in 8 2/3 innings. He walked just two against the Cubs.

“He was back in the zone with all his pitches,” Kelly said. “His changeup was really good, and his fastball command was much better today.”

The Cubs cut the deficit to 6-4 in the seventh but stranded two runners against Hunter Barco.

Two walks and a single loaded the bases with one out. Bregman hit a popup that pulled second baseman Lowe into shallow right field. Lowe stumbled after catching the ball, and that allowed Swanson to score on the sacrifice fly.

Barco kept the damage minimal when he got Happ to ground out to second.

Lawrence wasn’t as fortunate. Walks to Suzuki and Swanson were his undoing.

“I’m frustrated I couldn’t get the job done for the team,” Lawrence said. “It’s as simple as that. We’re playing really good baseball. I feel like it’s not the first time I’ve messed up our momentum. … I get it, it’s early, but if I do what I’m supposed to be doing, our record is even better.”