Johnson ran for 127 yards on 28 carries. Stanback added 74 yards and a pair touchdowns on nine tries.
The victory put the Knights (7-1, 4-0 ACC) in first place in the American Athletic Conference, ahead of the Cougars (7-2, 4-1).
But they needed a goal-line stand in the final minute to secure the win.
Wayne Beadle hauled in a 12-yard TD pass from John O'Korn to pull Houston within 19-14 with 4:04 remaining, and the Cougars then got the ball back at their 38-yard line with 3:02 left.
They eventually moved to the UCF 10-yard line with three chances to score, but stalled there as consecutive passes by O'Korn fell incomplete.