ORLANDO, Fla. (AP) -- Detroit coach Lawrence Frank wanted his team to finish a tough road trip on a positive note.
The Pistons did that, and provided some late-game toughness.
Brandon Knight had a career-high 31 points, including five 3-pointers, and Greg Monroe scored 17 points, helping the Pistons stave off three game-tying field goal attempts in the closing seconds of their 104-102 victory on Sunday night.
''It was good to see how we responded.'' Frank said of the win, which also snapped a two-game losing streak. ''There were 20 lead changes in that game. We kept our poise and our resolve.''
Will Bynum also had a season-high 12 assists on a night in which the Pistons were under their season average for turnovers and assisted on 25 of their 40 field goals.
''The ball bounces funny sometimes,'' Knight said. ''But still, you've got to be there and get some of those bounces and make some of the effort plays ... I gotta commend my teammates on making some of those effort plays toward the end of the game.''
The loss spoiled a big night for J.J. Redick, who tied a career high with 31 points and set a career high with eight 3-pointers.
Jameer Nelson had 18 points and eight assists, and Glen Davis added 17 points and 12 rebounds.
The Magic have lost five straight games, including 10 of 11 at home. They've also lost 10 straight games to teams with records below .500.
''We tried,'' Magic coach Jacque Vaughn said. ''I keep believing that it's going to turn in our favor, to be honest with you. I'm genuine. I'm upfront with them. I tell them as fair as I can, that you continue to work hard, you don't skip steps. ... We will continue to be resilient, continue to push guys, but continue to hug them at the same time.
''That's what we do.''
The lead changed hands 10 times in the final period.
The Pistons led 93-89 on a 3-pointer from the wing by Knight with just over six minutes to play. It would grow to five points a few possessions later on a floater by Bynum.
The Magic found a way to rally. E'Twaun Moore connected on a deep 3 to trim Detroit's lead to 95-93. A Nikola Vucevic dunk tied it up, and Moore's three-point play off a steal put the Magic up 98-95 with 2:50 left.
Detroit's rebounding kept alive back-to-back possessions, each ending in 3-pointers by Knight, to put the Pistons back in front 101-98.
The Magic got it back to 103-100 on another basket by Moore, but Davis came up short on a jumper, giving the Pistons the ball with under a minute to play.
Orlando pulled down the rebound on a Detroit miss, but Redick fired an air ball from 3 on the other end, which was corralled by Detroit.
Bynum was fouled with less than 10 seconds left and got 1 of 2 free throws to make it 104-100.
Nelson was fouled on a 3-point attempt. He made 2 of the first 3, but the third rattled out.
During a scramble for the rebound, the Magic got off three attempts that would have tied it, but came up empty as time expired.
The Pistons took a 10-point lead into the break, but it was Redick who was the star of the first half.
Redick scored 16 of the Magic's first 18 points to start the game, and knocked down 6 of his 7 attempts from beyond the arc as Orlando took a 32-29 lead.
The rest of the Magic's lineup struggled to support him offensively, though, as Detroit responded with a 15-0 run to retake control. Redick was 7 for 10 from the field in the opening 24 minutes, compared to 9 for 33 for the rest of his teammates.
Redick said he hopes the Magic keep a positive mindset as they begin a five-game road trip beginning Monday at Brooklyn.
''It just seems like it's getting more and more frustrating,'' he said. ''The way we're losing is tough. But we can control our mindset, our attitude, our perspective over these last nine games before the break. We have a chance to use this road trip to get better, and we will.''
The Pistons get one day off before hosting Milwaukee on Tuesday.
Frank said ending the road trip with a win was big.
''It's really great,'' he said. ''We had a very tough loss after being up 17 in Chicago, (and) a very disappointing performance in Miami where we underperformed. Today, even though it wasn't perfect, the spirit was. Great collective team win. Great fight.
''I think our guys showed some great resolve and I think it's good to finish the trip on a positive note.''
Notes: Davis received a technical foul with 8:33 left in the third quarter. It was the fourth straight game he has received a technical and is his fifth of the season. ...The Pistons earned just their fifth road win of the season, improving to 5-16.
Follow Kyle Hightower on Twitter at http://www.twitter.com/khightower