He found Hakeem Nicks with a 74-yard pass with 9 minutes remaining, then coolly found Foster in the right corner of the end zone in the final minute to give North Carolina (3-1, 1-1 Atlantic Coast Conference) its first lead of the day.
Marve nearly hooked up with Farquharson again on the final play of the game, but Goddard's second pick of the quarter sealed the Tar Heels' win. Farquharson had his hands on the ball in the end zone, yet Goddard was the one who wound up with possession.
Marve threw three touchdown passes for Miami (2-2, 0-1), and Graig Cooper rushed for 113 yards plus had a receiving TD for the Hurricanes, who lost to the Tar Heels for the second straight season.
A year ago, Miami almost pulled off a stunning comeback against North Carolina, nearly rallying from a 27-0 halftime deficit.
This time, the Tar Heels showed the Hurricanes how to pull one of those off.
Down 24-14 midway through the fourth quarter after Marve connected with Aldarius Johnson on a 4-yard touchdown pass, the Tar Heels went to work. Nicks caught the ball ahead of a diving Bruce Johnson for the first North Carolina touchdown of the final quarter, seeming to stun the Hurricanes a bit, and then Sexton delivered the perfect touch pass at the end.
It was a stirring turnaround, especially considering how the game started.
The Hurricanes needed only eight plays to go 89 yards - with Cooper rushing three times for 60 of them - on the opening drive, capped by Marve finding Farquharson with a 9-yard touchdown pass.
A special-teams blunder by the Tar Heels later in the opening quarter gave Miami a two-touchdown edge.
North Carolina punter Terrence Brown dropped a snap, fell on the ball at the Tar Heels 11, and the Hurricanes quickly capitalized. Marve lofted the ball to Cooper on a middle screen that resulted in an 11-yard TD for a 14-0 lead.
Miami made it look easy in the first 15 minutes, outgaining North Carolina 127-24, limiting the Tar Heels to minus-4 yards rushing and less than two yards per play.
Suddenly, everything that went right in the first quarter suddenly stopped for Miami.
Greg Little's 8-yard run early in the second quarter helped draw North Carolina within 17-7 at halftime, and Ryan Houston scored from 2 yards out midway through the third to draw the Tar Heels within 17-14.