When the Nets needed a basket last night against the Pistons, their All-Star bailed them out.

Leading 89-88 with 32.5 seconds remaining, Nets interim coach P.J. Carlesimo could have easily drawn up a play for either Deron Williams or Joe Johnson. But Carlesimo opted instead to design a play to get the ball to Brook Lopez in the post.

Lopez rewarded his coach for his faith, and after backing Pistons big man Greg Monroe down into the low block, powered through him for a layup with 17.8 seconds left and send the Nets on their way to a 93-90 victory in front of 12,576 inside The Palace of Auburn Hills.

“He’s playing excellent,” said Gerald Wallace. “He’s playing like an All-Star. The things he demands and the attention he demands on the court is amazing, and it’s credit to his work ethic.

“He’s our go-to guy on the block.”

The Nets (29-20) went to Lopez on the block late in Tuesday’s loss to the Lakers, only to see him twice miss shots, and also make some mistakes at the other end of the floor that led to Lakers baskets.

Lopez after that game took full responsibility for the loss — one of a few Nets to do so — but when presented with the same opportunity again last night, he made sure it wasn’t the same outcome.

“I think it was definitely convenient timing, having that game right after [losing to the Lakers],” Lopez said with a smile after finishing with 17 points, nine rebounds and two blocked shots.

“I was just in the mindset that I wanted to go up strong and, more importantly, make the right play. If there was another guy coming to double, get it to the open guy. But they stayed in single-coverage, so I wanted to be aggressive and be strong.”