MIAMI GARDENS, Fla. — N'Kosi Perry threw for a touchdown on the opening drive and ran for another with 2:31 remaining, and Miami knocked off No. 20 Virginia 17-9 on Friday night.

Deejay Dallas caught the touchdown pass for Miami (3-3, 1-2 Atlantic Coast Conference), plus rushed for 63 yards on 13 carries. Pat Bethel blocked a field goal for Miami and K.J. Osborn caught four passes for 60 yards.

Perry finished 16 of 27 for 182 yards. The win kept the Hurricanes from falling to 0-3 in conference play — any conference — for what would have been the first time in school history.

Bryce Perkins connected on his first nine passes and finished 24 for 41 for 244 yards for Virginia (4-2, 2-1). The Cavaliers entered ranked, yet were still 2 1/2 point underdogs at kickoff. And apparently, those oddsmakers saw this coming.

Brian Delaney made three field goals for the Cavaliers, who were looking for their first 3-0 start since 2007. They're now tied with North Carolina for first place in the Coastal Division, and could be joined there by Duke if the Blue Devils beat Georgia Tech on Saturday.

Miami went 78 yards in 11 plays on the game's first possession, with Dallas taking a short pass from Perry and rumbling the rest of the way for a 17-yard score. Perry was under pressure, wound up flipping the ball to Dallas — who caught it well behind the line of scrimmage, but ended up darting into the right side of the end zone. The Hurricanes' next six drives went nearly nowhere — 33 yards on 23 plays, all six possessions ending in punts.

But the defense, which head coach and former defensive coordinator Manny Diaz said he was taking more of a role with this week, did its part to keep Miami in front. Virginia got inside the Miami 30 on six separate possessions, and came away with only three field goals on those drives. The others ended on downs, a fumble and the blocked field goal in the second quarter.

And Miami finally got moving in the fourth, getting to the Virginia 3 after trying a little of everything — even tight end Brevin Jordan's first career carry. But they settled for a field goal, going up 10-6.

Virginia got within 10-9 on the ensuing possession despite a seven-play, zero-yard drive. Joe Reed's 72-yard kickoff return was enough to get the Cavaliers in range, and Delaney connected on his third field goal of the night. Miami then went 75 yards for the clincher, Perry's straight-ahead 3-yard rush for a score.