The quarterback finished with 105 yards rushing and completed 15 of 19 passes.
Houston (5-4, 4-2 Conference USA) came back from a 17-point deficit to take a 24-23 lead in the third quarter.
The Knights (7-2, 5-0 C-USA) regained the lead on a 1-yard run by Godfrey with 1:42 remaining in the third.
The Knights upped their lead to 13 on Latavius Murray's 2-yard touchdown run and Nick Cattoi's 27-yard field goal halfway through the fourth.
The Cougars cut the lead to seven with a 36-yard touchdown pass from David Piland to Patrick Edwards with 5:46 left in the game. After Cattoi missed a 39-yard field goal with 1:53 remaining, Houston had one last chance to tie it, but the Piland's pass on fourth down was broken up.
Murray rushed 11 times for 78 yards and a touchdown, and Jamar Newsome caught five passes for 123 yards to lead UCF.
Piland finished 27 of 44 for 334 yards, four touchdowns and two interceptions. Edwards finished with 10 catches for 162 yards and three touchdowns, and Michael Hayes had 20 carries for 113 yards.