The Panthers (5-5, 2-4) drove to the North Carolina 26 with under 2 minutes remaining but the Tar Heels stuffed Pitt running back James Conner on fourth-and-1 and escaped.
North Carolina quarterback Marquise Williams ran for two touchdowns to overcome a shaky day passing and the Tar Heels sacked Pitt's Tom Savage seven times.
Savage shook off constant pressure and a knee injury to complete 23 of 38 passes for 313 yards and two touchdowns, both of them coming during a frantic second-half surge by the Panthers after they spotted the Tar Heels a 27-3 lead.
A 2-yard plunge by Conner tied the game at 27 with 8:52 left, Pitt's defense held and the Panthers actually had the ball at their own 8 with a chance to move in front. Three plays produced four yards and punter Matt Yoklic lifted a 50-yard kick that Switzer had to drift back and grab at the North Carolina 39.
One block gave the freshman the edge and he cut back across the field - running through a pair of tackles in the process - and sprinted into the end zone for his second score of the day and third in two weeks. Switzer's two touchdowns set a school record for most punt return scores in one game. His three touchdowns are also a school record for most in one season.
The victory continued North Carolina's unlikely rise following a 1-5 start. The Tar Heels came in having won three straight by an average of 21 points and seemed to be well on their way to making it four straight routs when Thomas Moore's second field goal put them up 24 with 12:51 left in the third quarter.
The Panthers were coming off an emotional high after rallying to beat Notre Dame last weekend, a victory that moved Pitt to the cusp of bowl eligibility and served as the most significant triumph of coach Paul Chryst's brief two-year tenure.
Chryst allowed he wasn't sure how his team would respond and was treated to another uneven performance in a season full of them.
The Panthers marched 64 yards on the opening drive for a field goal and was deep in North Carolina territory on its second drive when Savage scrambled to his left and had the ball knocked out of his hand by Martin. Travis Hughes recovered and in an instant Pitt's momentum vanished.
North Carolina ripped off the game's next 27 points. Williams dashed in from 16 yards out - completely freezing Panthers defensive back Anthony Gonzalez - to give the Tar Heels the lead. After a Thomas Moore field goal, Williams ran through a pair of arm tackles during a 10-yard sprint around left end to make it 17-3.
The Panthers had no answer as North Carolina's rejuvenated defense, which was so abysmal earlier in the season and associate head coach Vic Koennig said he was "disenchanted" by his group's play, attacked Savage relentlessly.
During one five-possession span in the second and third quarters, Savage endured six sacks, avoided another by intentionally grounding the ball by switching the ball to his left (non-throwing) hand and injured his left knee at the end of a lengthy scramble.
Still, he hung around and put the Panthers in position for one of the biggest comebacks in the program's lengthy history, a bid that ended when Conner found no space to move on fourth down with 1:10 left.