BIRMINGHAM, Ala. -- The UAB Blazers rallied just when it seemed they might let another game slip away.
Ty Long kicked a 40-yard field goal with 21 seconds left to give UAB its first victory of the season Thursday night, 26-24 over Central Florida.
The Blazers (1-6, 1/3 Conference USA) converted two third-and-longs after taking over at their own 16 with 4:57 left to set up the game-winner.
They had dropped two games by five points or fewer and blew a nine-point lead in the fourth quarter this time before rebounding and finally getting something to celebrate.
"The satisfaction of winning a football game is mighty big for us," UAB coach Neil Callaway said.
The Knights (3-4, 1-2) got the ball across midfield with 14 seconds remaining on a kick return by Rannell Hall, whose returns helped set up all three TDs.
Backup quarterback Blake Bortles threw an incomplete pass and then had a last-play heave intercepted by Chase Daniel at the goal line.
"It feels so good to finally get that monkey off your back," said wide receiver Jackie Williams, who had 10 catches for 82 yards and ran for a fourth-quarter touchdown.
Bortles had led two fourth-quarter scoring drives after relieving Jeff Godfrey to rally the Knights from a 23-14 deficit, but couldn't keep UCF from losing for the fourth time in five games.
"I was just trying to get the first one out of the way," Perry said of the touchdown passes.
All those numbers were career highs, and his completions put him in a four-way tie for second-most in UAB history.
He has started three of the past four games with Ellis out with injuries.
The backup threw two interceptions in the end zone but came up big at the end -- with a little help from a timely flag.
Patrick Hearn caught a 22-yarder while falling backward on third-and-12 to push the Blazers across midfield. On third-and-16, Lyle Dankenbring was called for pass interference.
"We knew that we had to run as much time as we could off the clock," Callaway said. "And the play with Pat Hearn making a heck of a catch on their sideline put us in great position for the field goal."
Long split the uprights after three straight runs by Darrin Reaves. UCF had taken the lead on Shawn Moffitt's 24-yard field goal.
UAB gained 501 yards against the nation's No. 3 defense while holding UCF to 331. Perry also ran for 33 yards on eight carries, while Reaves gained 83 yards.
"I think it's as sloppy defense as I've ever seen just as far as making plays," UCF coach George O'Leary said. "The coverage wasn't good and things you can't do in games and expect to win. Disappointing."
The Knights lost the time of possession battle for the first time this season, holding onto the ball for nearly 10 minutes less than their average of 35 minutes, 30 seconds.
The Blazers' first win didn't come without plenty of tense moments.
The Knights came right back after O'Leary inserted Bortles in the fourth quarter. Hall put him in good position for his first drive by returning a squib kick 39 yards to the UAB 41.
Bortles then completed his first four passes before Latavius Murray ran for the final yard to cut the gap.
Bortles passed this time to Murray, who made a nice cutback move en route to a 53-yard gain to set up a first-and-goal from the 6 for UCF on the next drive.
One run went nowhere and Bortles threw two incompletions to force Moffett's kick.
"I thought we should have put Blake in sooner," O'Leary said. "Obviously he had a little better grasp of what was going on out there."
Godfrey was 13 of 22 for 133 yards and an interception and directed touchdown drives on UCF's first two possessions, capped by leading rusher Brynn Harvey's first touchdowns of the season. Bortles was 6 of 10 for 102 yards, all in the final quarter.
The Blazers were also playing without injured tailback Pat Shed and an ailing left tackle Matt McCants.
Jackie Williams scored on a 4-yard end around on third-and-goal for the nine-point lead in the opening minute of the fourth.
Then the UCF defense came up big. Troy Davis and Kemal Ishmael stuffed Perry on fourth-and-2 from the UCF 32 midway through the fourth.
That set up the go-ahead field goal.
Long had given UAB a 16-14 halftime lead with a 45-yard field goal on the final play after Perry took over with 34 seconds left. He delivered a 25-yard pass to Nolen Smith and a 12-yarder to Williams to move into field goal position.
UCF had also missed a field goal in the half.