David Wilson rushes for 128 yards on 23 carries while his counterpart for Miami, Lamar Miller, runs for 166 yards and one touchdown on 18 carries in one of the game’s marquee matchups. (Don Petersen/AP)

Logan Thomas had already done plenty Saturday to dispel the notion that he’s not ready to lead Virginia Tech’s offense this season.

But with less than three minutes remaining in the fourth quarter and Miami up by four points, the Hokies’ first-year quarterback stood on the sideline discussing the tenuous situation with his predecessor, Tyrod Taylor, who was in town because the NFL’s Baltimore Ravens are on a bye week. And before Thomas headed back onto the field, Taylor delivered a simple message: “This is where legends are made. This is where you start your legacy.”

Thomas then put an exclamation point on an afternoon that should put to rest any remaining doubts about his capabilities. After the Hokies’ defense coughed up a 10-point fourth-quarter lead, Thomas’s 19-yard touchdown run with 56 seconds left lifted No. 21 Virginia Tech to a wild 38-35 victory over Miami in front of 66,233 fans at Lane Stadium.

Thomas completed 23 of 25 passes for a career-high 310 yards and finished with five touchdowns (three passing, two rushing). Even more notable: The performance came just a week after Virginia Tech’s 23-3 loss to Clemson, when the Hokies’ offense was held without a touchdown in a home game for the first time since 1995.

“I said I wanted to get better, but I wasn’t expecting this much better,” said Thomas, whose completion percentage (92.0) was the highest for a quarterback in a single game during Coach Frank Beamer’s 25 seasons at Virginia Tech.

Most important, the win kept the Hokies (5-1, 1-1) just one game behind undefeated Georgia Tech in the ACC’s Coastal Division standings. No team has ever won an ACC championship after starting conference play 0-2.

But the victory could have easily turned into a deflating collapse if not for the heroics of Thomas and the Hokies’ offense, which gained a season-high 482 yards.

Virginia Tech led, 21-7, at halftime and took a 24-14 lead into the fourth quarter. But the Hokies’ defense, which had shown considerable improvement through five games this season, couldn’t figure out how to stop Hurricanes running back Lamar Miller.

Miller had 146 rushing yards in the second half alone and finished with 166 for the game. Not only did he outduel Virginia Tech’s David Wilson (128 yards rushing, one touchdown), Miller also had two touchdowns in the fourth quarter. The first brought the Hurricanes within 31-28 and came on a trick play in which wide receiver Phillip Dorset found Miller in the corner of the end zone for a diving 16-yard catch.

The Hokies’ defense actually had the Hurricanes stopped on the drive when defensive end J.R. Collins sacked quarterback Jacory Harris on third down near midfield. But officials called an unsportsmanlike conduct penalty on Collins for throwing the ball in Harris’s face after the play, and Miami received a first down.

Then, with less than three minutes remaining in the game and Miami facing third and goal from the Hokies 30 because of penalties, Miller burst through a hole for a 30-yard touchdown run.

It compounded a frustrating afternoon for Virginia Tech’s defense, which gave up a season-high 519 yards, including 337 after halftime. It didn’t help that the Hokies lost starting defensive end James Gayle (ankle) and linebacker Jeron Gouveia-Winslow (foot) to injuries on the first drive of the game.

But every time Miami mounted a charge — the Hurricanes scored touchdowns on every second-half possession expect their last when time expired — Thomas and the offense had an answer.

He completed 5 of 6 passes on the Hokies’ opening touchdown drive, and entered halftime having completed 15 of 16 passes for 191 yards and three total touchdowns. Then, when Harris (13 of 21 for 267 yards and three touchdowns) found wide receiver Tommy Streeter for a four-yard touchdown pass early in the fourth quarter, Thomas responded on the Hokies’ next play from scrimmage with a 60-yard touchdown to wide receiver Jarrett Boykin, the longest completion of his career.

“Every time they closed, our offense came back,” Beamer said. “This is a great win . . . and the way it came about I think said a lot about our people on this football team.”

The biggest statement, though, belonged to Thomas. As Virginia Tech faced fourth and one from the Miami 19-yard line late in the fourth quarter, Thomas said, “I wasn’t nervous at all.”

So after a timeout, play-caller Mike O’Cain changed the call from a short pass to a designed quarterback run, and Thomas remembers his teammates telling him, “Go get this one.”

“I stepped through the hole and there was nothing there,” Thomas said. “I guess the rest is history.”

Just like Taylor told him before the series began.