DETROIT (AP) - For a few moments Friday, Stan Van Gundy thought his Detroit Pistons were going to fall back into the same bad habits that plagued them early in December.
After leading for most of the game, the Pistons found themselves trailing the New York Knicks by four with 1:48 to play. A loss would have dropped them to 3-9 in December and a game behind the Knicks in the Eastern Conference standings.
Instead, Detroit finished with a 9-2 run to post a 104-101 victory and a fourth win in five games.
"Down four in the last two minutes is a bad situation, but I was very happy with the way we closed out the game," Van Gundy said. "We made some big defensive plays and Reggie (Jackson) attacked on the offensive end."
Jackson's runner in the lane made it 101-101 with 44 seconds left, and Ron Baker turned the ball over at the other end. Jackson then split a pair of free throws to give the Pistons a one-point lead with 23.7 seconds to go.
Stanley Johnson forced Courtney Lee into a bad shot, then hit two free throws to put Detroit up 104-101.
"I was going to attack the rim, but they cut me off, so I tried to step through and take the shot," Lee said. "I thought there was contact, so I leaned in, but they didn't call the foul."
Kristaps Porzingis missed a desperation 3-pointer at the buzzer.
"At the end of the game, we were going to switch everything to make sure we always had someone on Porzingis," Van Gundy said. "He's 7-foot-3, so he can shoot over anyone, but our guys were making it as tough as possible."
Andre Drummond finished with 18 points and 15 rebounds, while Tobias Harris scored 24 points. The Pistons had seven players in double figures, including reserves Johnson and Ish Smith.
"The loss (Wednesday) in Dallas really hurt, because we didn't play with any energy in the second half, and we let them have a good run," Drummond said. "Tonight, we tried to come out and put a lot of effort into the game."
New York had won five of six, including a victory Thursday night over the Boston Celtics. Porzingis finished with 29 points on 28 shots, and Enes Kanter added 22 points and 16 rebounds.
"We weren't able to get going downhill all night," Knicks coach Jeff Hornacek said. "We only got six free throws, so there wasn't a lot of penetration and we took a lot of outside shots."
The Pistons pulled down four offensive rebounds in the first two minutes on their way to a 12-2 lead. Drummond had six points and six rebounds early, but the Knicks got back into the game when he went to the bench with two fouls.
Drummond was limited to seven minutes in the half, but the Pistons still led 52-44 at intermission. Harris and Anthony Tolliver each scored 10 points, while Porzingis had 10 points and six rebounds for the Knicks.
Kanter's follow shot gave the Knicks a 69-68 lead with three minutes left in the third, and he followed with another on the next possession. New York finished with an 18-2 run to move the margin to 75-70, but the Pistons scored the quarter's final four points to get within one.
"We really have to work on our third-quarter defense, because this is three games in a row where it has gotten us into trouble," Van Gundy said. "It's really the whole second half, but especially the third quarter."
Detroit kept that surge going in the fourth, starting the period with a 10-4 run to lead 84-79 with 10:03 to play.
The Knicks tied the game with 3:45 left when Drummond was called for goaltending, and Porzingis followed with a mid-range jumper to put New York ahead 95-93. After the teams traded baskets, Harris missed and Jarrett Jack hit a short jumper to make it 99-95 with 1:48 to play.
Knicks: Guard Tim Hardaway Jr. missed the game with a leg injury, but was called for a first-quarter technical for arguing a call. His father was on the opposite bench as one of Van Gundy's assistant coaches.
Pistons: Avery Bradley missed his fourth straight game with a groin injury and is expected to be out until at least New Year's Day.
Knicks: Host the Philadelphia 76ers on Christmas Day.
Pistons: Host the Indiana Pacers on Tuesday.