Rosier's 49-yard pass to Ahmmon Richards with 11:02 to play marked the first points of the second half and pushed the Hurricanes to a 24-6 lead.
There was concern for the Hurricanes (3-0, 1-0 ACC) when standout running back Mark Walton went down with an injury before walking off the field with 7:37 to play. He didn't return. It is unclear what his status is for Miami's next game in eight days at Florida State.
Backup Travis Homer ran for a 40-yard clinching touchdown with 4:48 left.
Rosier, a redshirt junior who made his first career start two years ago in this stadium, completed 15 of 26 passes for 270 yards.
The Blue Devils (4-1, 1-1) have lost their last four meetings with Miami.
Duke quarterback Daniel Jones finished 21 of 41 for 166 yards after going 1 of 9 in the fourth quarter. Johnathan Lloyd made nine catches for 82 yards, all in the first half.
Miami led 17-6 at halftime, though Duke held a 224-214 edge in total offense.
Rosier was 8-of-8 passing in the first quarter. The Hurricanes opened the second quarter in Duke territory, but back-to-back sacks thwarted that drive.
After the second stalled possession for Miami, linebacker Michael Pinckney made a diving interception of a ricocheted pass as the Hurricanes took over at the Duke 40. The Blue Devils stopped two plays from inside the 1, with Miami settling for Michael Badgley's 20-yard field goal for a 17-3 lead.
Duke countered with Austin Parker's 35-yard field goal on the last snap of the first half.
The Blue Devils drove 56 yards on the opening drive, reaching the Miami 13. But on fourth-and-1, Pinckney sacked Jones.
The Hurricanes wasted no time in scoring, with Rosier throwing as he was hit and connecting with Braxton Berrios in the end zone for a 27-yard touchdown.
The Hurricanes were back in the end zone on Rosier's 1-yard run less than four minutes later. Duke closed within 14-3 on Parker's 27-yard field goal with 1:13 left in the first quarter.
Miami called timeout 10 seconds into the game and challenged a ruling on the field, but the call wasn't overturned.