DETROIT (AP) _ Guard John Bagley hit a layup with three seconds on the clock Friday night as the Cleveland Cavaliers fought off a Detroit comeback and edged the Pistons 119-118 in National Basketball Association play.

The Pistons had taken the lead, 118-117, on a three-point jump shot by guard Isiah Thomas with 43 seconds remaining.

The Pistons called time out with two seconds remaining. But forward Kelly Tripucka, who had a team-high 25 points, threw an errant in-bounds pass to center Bill Laimbeer and Detroit could not attempt a final shot.

The Cavaliers saw a 68-56 halftime lead evaporate in the final quarter, as Piston reserve guard Vinnie Johnson sank two free throws with 5:07 remaining to give the Pistons their first lead of the night, 107-105. The Cavaliers regained the lead, 115-113, on a layup by Bagley with 2:14 left and never trailed again until Thomas hit his three-pointer.

Guard World B. Free scored 23 of his game-high 37 points in the first quarter to give Cleveland an early 39-28 lead.

The victory gave Cleveland a 34-43 record in the Central Division, while playoff-bound Detroit fell to 41-36. With the victory, the Cavaliers took a three-game lead over the idle Atlanta Hawks in the battle for the final Eastern Conference playoff spot.

Bagley finished with 28 points for the Cavaliers, and forward Phil Hubbard added 18.

Thomas and Laimbeer scored 23 points each for the Pistons, while Johnson contributed 18.