The Nets’ 80 percent first-quarter shooting had cooled all the way to 25 percent in the final quarter, point guard Jeremy Lin was on the bench with a strained left hamstring, and a 21-point lead was down to four when Pistons star Tobias Harris buried a left-wing three with 38.9 seconds left last night at Barclays Center.

Suddenly, the Nets’ “Brooklyn grit” motto was in for a severe test.

That’s where power forward Trevor Booker, who earlier asserted himself as the Nets’ enforcer in a tussle with 6-10, 260-pound Pistons power forward-center Aron Baynes, came up with a series of hard-nosed plays. Booker forced a Detroit turnover, ran down Kentavious Caldwell-Pope to block a layup from behind and finally grabbed a key offensive rebound before Brook Lopez hit a pair of free throws for some breathing room in what became a 109-101 Nets victory.

Lopez, who totaled a season-high 34 points and 11 rebounds, converted the free throws for a 107-101 lead with 14.9 seconds to play, and the Nets improved to 2-3 with a hard-fought win over a playoff team. Sean Kilpatrick, who had to move to point guard after Lin went out, added 24 points and 10 rebounds for the Nets, and Joe Harris had 13 points.

The Pistons (3-2) were topped by Harris, the Islip native, and Marcus Morris with 23 points apiece, but powerful center Andre Drummond was limited to six points and six rebounds and was benched in the final period.

Although the Nets made only four of 16 shots in the final period, they held the Pistons to just 20 points. It was an early-season barometer of their toughness.

advertisement | advertise on newsday

“It shows a lot,” Booker said. “We’ve been working hard. We lost our point guard in Jeremy, who means so much . . . We made some big plays down the stretch. It was a tremendous game by everyone, defensively by me and offensively by Sean and Brook. It was a great team effort.”

Coming off a 30-point loss to the Bulls on Monday, the Nets put the Pistons on their heels by making their first nine field-goal attempts before Rondae Hollis-Jefferson finally missed with 6:03 left in the first quarter. The Pistons kept pace until the Nets put together a 9-2 burst to reach the end of the period with a 38-30 lead on 16-of-20 shooting.

There was barely any let-up in the second quarter as the Nets pushed their halftime lead to 71-55 with their shooting still at 70.7 (29 of 41). There was no greater revelation than Lopez, who had 24 first-half points, including 4-of-5 marksmanship from three-point range. The 7-foot center came into the game 4-for-38 for his career beyond the arc, but he has been working relentlessly on it with coach Kenny Atkinson.

“That’s going to be part of our offense, so, you’re going to have to get used to it,” Atkinson said of “Long-Distance” Lopez.

Lin was not on the floor for the second half, leaving point guard duties in the hands of rookie Isaiah Whitehead and Kilpatrick because vets Greivis Vasquez (ankle) and Randy Foye (strained right hamstring) also were out. Lin was not available after the game, and there was no injury update.

“It was tough to be out there without Lin,” Lopez said. “It’s great to see the guys stick together and trust each other. Like I’ve been saying, that’s where we will find out true strength and that’s what’s going to make us a great team.”