ORLANDO, Fla. (AP) The Orlando Magic entered their season-finale looking for momentum to take into the offseason.

For a while in the fourth quarter it looked like the Magic's season of disappointment would end in yet another frustrating defeat as they allowed the Detroit Pistons to chip away at a one-time 21 point advantage and eventually take the lead.

That's when Elfrid Payton took over, helping return the momentum and the lead back Orlando favor with three consecutive baskets in the final 1:12 to deliver the 113-109 win in clash of two non-playoff teams Wednesday night.

''We just wanted to end the season with a win,'' said Payton, who finished with 21 points and 13 assists. ''We talked about that yesterday and this morning so it was good for us to go out there and compete and win this last game.''

Payton pulled the Magic from a one-point deficit when he hit the first of three pullup jumpers off pick and rolls, making it 107-106 with 1:12 to play. Then he all but sealed the game on a 14-foot pullup jumper that pulled the Magic out front 111-106 and sent the sold out crowd at Amway Center into a frenzy.

Magic coach Frank Vogel couldn't have been more pleased to see Payton takeover in the end after a season that was filled with ups and downs for the young point guard.

''We put the ball in his hands on the pick and roll and said go win the game for us kid and he did,'' said Vogel, whose team finished a disappointing 29-53 in his first season. ''That was pretty awesome.''

Aaron Gordon also had an impressive game with 32 points and 12 rebounds and Nikola Vucevic also had a double-double with 18 points and 11 rebounds.

It was a good bounce back win for the Magic after suffering their worst loss of the season on Monday when they fell to the Chicago Bulls by a season-worst 47 points.

''We're trying to build a winning culture here,'' Vogel said. ''That message is the right one and it should resonate and carry into next year.''

The feeling about the ending wasn't nearly as positive coming out of the Piston's locker room after the starters fell into a 21-point first quarter deficit only to see the reserves help pull them out by outscoring Orlando in the second, third and fourth quarters. Detroit also held a brief four-point lead in the fourth quarter only to see that slip away after missing key shots down the stretch.

Starters Kentavious Caldwell-Pope and Ish Smith led the Pistons with 20 points each but the other three double-digit scorers came off the bench.

''That game was our season, wasn't it,'' said Detroit coach Stan Van Gundy, whose team's season ended at 37-45. ''Always down early, our starters never get us off, or rarely get us off to a good start. Down early, come back, which we do most of the time, and bad shooting at the end.

''I mean you pretty much, in one game, saw us for what we were this season. We had some resilience to come back and we can't shoot. That's got to change.''

TIP-INS

Pistons: Van Gundy said he decided to play Tobias Harris in the season finale because this marks the first time in his career he has played in all 82 games in a season. ... The Pistons missed their first six 3-point attempts of the first quarter and ended the quarter converting just one for nine from 3-point range. ... The Pistons had three reserves score in double figures with Bullock scoring 17, Ellenson scored 12 and Boban Marjanovic had 14 points and 11 rebounds.

Magic: Vucevic finished the season with a team-high 38 double-doubles. ... Forward Jeff Green, who will become a free agent this offseason, missed his ninth straight game due a back injury. ...The Magic's new D-League franchise that will play in Lakeland, Fla. beginning next season will also be named the Magic, the team announced Wednesday. ... The Magic converted six of 10 from 3-point range in the first quarter to help them take a commanding 21-point lead going into the second quarter. ...The 19,458 in attendance at Amway Center was announced as the largest home crowd in Magic history. ... Mario Hezonja's 11 rebounds were a career high.

Copyright 2017 by Associated Press. Any commercial use or distribution without the express written consent of Associated Press is strictly prohibited.