Johnson, who rushed for 59 yards in the first quarter, scored on runs of 11 and 2 yards on the Knights' first two drives. UCF ran on 10 of 11 plays on the two marches to take the initial momentum.
Baylor climbed back by creating turnovers.
Bears cornerback Demetri Goodson intercepted a long Bortles pass at the Baylor 3 to stop one Knights drive, and linebacker Eddie Lackey set up a Baylor touchdown with an interception at the UCF 32.
Baylor needed just two plays to score after Lackey's pick. Petty hit Levi Norwood over the middle, and the wide receiver evaded the UCF secondary for a 30-yard touchdown.
Bortles made up for the two interceptions with some help from wide receiver Rannell Hall (four catches, 113 yards). Bortles connected with Hall on a short pass near the line of scrimmage at midfield, and Hall slipped a defender and outran the Baylor defense for a 50-yard touchdown.
Hall's score boosted the Knights' lead to 21-13 with 5:05 left in the first half.
Baylor kept punching back, though. Petty answered Hall's score by running for a 13-yard touchdown, accented by a flip into the end zone when UCF defensive back Jacoby Glenn hit the diving quarterback in the legs.
Bortles then led UCF on a nine-play, 83-yard touchdown drive, capped by another catch-and-run touchdown to Hall, this one going 34 yards. The extra point gave the Knights a 28-20 halftime lead.
NOTES: UCF and Baylor both began the season unranked and went on to win their respective conferences. UCF finished 8-0 in the American Athletic, while Baylor won the Big 12 with an 8-1 mark. ... Baylor has been ranked in the top 10 for eight consecutive polls, a program record. ... UCF entered on an eight-game winning streak, the longest in program history.