Updated

Joe Johnson hit the winning jumper at the buzzer of the second overtime to lift the Brooklyn Nets to a dramatic 107-105 win over the Detroit Pistons.

Johnson scored 28 points and a physical Gerald Wallace totaled 25 points and 10 rebounds to help the Nets win on a night they got Brook Lopez back in the lineup.

The Pistons got a fortuitous deflection to tie the game with 5.8 seconds left in the second OT. Brandon Knight missed a left baseline jumper, but Brooklyn's Kris Humphries tipped the ball to Kyle Singler, who was alone under the basket for a layup.

Following a timeout, the Nets got the ball to Johnson, who dribbled near the top of the arc. With his right foot cradling the 3-point line, Johnson's shot over the outstretched left arm of Tayshaun Prince went through the basket as time expired, leaving former Nets coach and current Pistons bench boss Lawrence Frank looking on in disbelief.

The Nets, and even comedian Jerry Seinfeld, sitting courtside, celebrated the end of Brooklyn's four-game home skid.

Lopez, who had missed the previous seven games due to a mild sprain of his surgically repaired right foot, had nine points. Deron Williams, who sustained a left quadriceps contusion in the first quarter, returned and had 17 points.

"I saw guys tonight that were fighters. We had a lot of adversity tonight," Nets coach Avery Johnson said. "I saw a bunch of tough-minded and physically tough guys out there. Joe closed the door for us. That was exciting."

Brandon Knight scored 22 for the Pistons, who lost their third in a row. Prince had 12 points, 10 rebounds and six assists, while Rodney Stuckey scored 19 and Greg Monroe added 17, but he missed two crucial free throws.

The Pistons held a 90-84 lead with 1:32 left in regulation, but the tenacious Nets eventually tied it with the next six points, culminated by Wallace's bucket off a miss from Johnson with 20.7 seconds to go. Wallace stretched over Jason Maxiell and the Nets' Andray Blatche to somehow tip the ball in the basket.

Knight missed a jumper at the other end, and Williams failed on a chance to give the Nets the win at the conclusion of regulation when his fallaway shot from the right wing missed.

Stuckey's floater in the lane gave Detroit a 100-98 lead with 41.4 seconds left in the first OT, but Wallace's physical presence helped the Nets force a second extra session. C.J. Watson missed a 3-point shot, but Wallace, falling down, corralled the loose ball as his head smacked floor. Wallace got the ball to Johnson, who saved it inbounds and the Nets called timeout with 27.2 seconds left.

Johnson then canned a floater in the lane with 18.9 on the clock, and Stuckey's jumper in the waning seconds hit the back of the rim.

The Nets didn't score in the second OT until nearly a minute left when Wallace drove the lane for a layup. After Prince missed poorly on a right side jumper, Johnson gave Brooklyn the lead with a smooth cross-over dribble move into the lane and scored over Prince with 26.2 seconds left for a 104-103 lead.

Monroe failed on two tries from the charity stripe nearly nine seconds later, with the second barely grazing the rim.

"It's a tough one to lose," Monroe said. "It's one of those games you definitely wish you would have gotten."

Johnson made 1-of-2 foul shots with 10.5 seconds remaining to set up the big finish.

The Nets were behind by two points after 12 minutes, but then shot 14-of-22 in the second quarter. Brooklyn was behind 37-33, but then embarked on a 21-1 burst, finished off by a Blatche layup.

It was 59-47 at the half, but the Pistons turned the tables in the third quarter with a huge 24-7 rally. Knight's 1-of-2 effort at the charity stripe concluded the run for a 77-71 lead for the visitors inside the final minute. Blatche then hit a layup for the final points of the quarter.

Game Notes

Blatche scored 16 and Maxiell 13 ... Detroit held a 54-33 rebounding advantage ... The Nets have won seven of the last nine at home against the Pistons.