NEW YORK — Michael Porter Jr. made a go-ahead layup with 5.4 seconds remaining after Brooklyn had blown a 20-point fourth-quarter lead, and the Nets beat the Chicago Bulls 112-109 on Friday night.

Porter scored 26 points and Noah Clowney had 23 points and 11 rebounds for the Nets, who snapped a five-game losing streak. Day’Ron Sharpe scored 14 points and rookie Danny Wolf had 13.

Nikola Vučević scored 19 points and Ayo Dosunmu 18 for the Bulls in the opener of a home-and-home series.

Coach Jordi Fernandez thought the Nets could’ve won all three games on their just-completed trip, but it appeared they wouldn’t need to worry about another close finish after a 15-0 run in the second quarter helped them take a 17-point halftime lead, their second-largest of the season.

Cam Thomas’ 3-pointer to open the fourth quarter made it 92-72 before the Bulls scored the next 11 points. Thomas hit another 3 to stop that surge, and the Nets still led by six with less than a minute remaining.

The Bulls then scored seven straight points to go ahead 109-108 on Tre Jones’ layup with 11.4 seconds remaining. The Nets ran a play to get Porter the ball near the basket, and he put the Nets back on top. Rookie Drake Powell then stole the Bulls’ pass in from the sideline, and Clowney’s two free throws made it 112-109 before Vučević missed a rushed 3-point attempt.

The Nets had a 42-38 lead with about 4½ minutes to play in the second quarter that should’ve been cut to two, but Matas Buzelis missed a fast-break dunk attempt with nobody around. Clowney then converted a pair of three-point plays during a personal run of seven points, and after Porter made a 3-pointer, Clowney hit one to extend the lead to 17 before Egor Demin made two free throws to end the run and make it 57-38.

Up next: The teams play Sunday in at the United Center.