An early try from Polu Uhi and a conversion and penalty from Ceiron Thomas had given Cardiff a remarkable 13-0 lead but when the visitors were given two yellow cards, Pontypridd took advantage.
Simon Humberstone had got the home side rolling with a penalty before an Adam Thomas try and a conversion from Humberstone made it 13-10 at the break.
The second half was as entertaining as the first, if not more so. Ceiron Thomas put Cardiff further clear with two more penalties and at that stage, Pontypridd were well up against it.
But Dale McIntosh's side showed bags of heart as well as their undoubted class to comeback and steal victory. Wayne O'Connor and skipper Chris Dicomidis crossed for quick-fire tries, Humberstone converting the first of those scores.
It meant Pontypridd led for the first time, their three point advantage proving enough come the final whistle.
The first half had started in the best possible way for the visitors. Giant wing Uhi, a summer signing from Championship side Ebbw Vale, made the most of Adam Thomas' failure to collect what looked like a speculative chip through. With few options outside him, Ceiron Thomas had been forced to kick ahead. There looked to be little danger initially but when the ball bounced, Uhi took advantage to crash over for the opening score. Ceiron Thomas converted from the touchline and then added a penalty in a dream first 10 minutes.
After staying unbeaten in the league at Sardis Road throughout all of last season, an early 10-0 deficit would have been a shock to Pontypridd's system. The home side were falling foul of Neil Hennesssy's whistle, often to the anger of the Sardis Road crowd but in truth, the defending Premiership champions hadn't really got started.
A second Ceiron Thomas penalty then put Cardiff further clear though the game was now much more of an even contest. Humberstone replied for Pontypridd with a simple three points as both sides continued to give away penalties.
In between further misses from Humberstone and Ceiron Thomas, Cardiff's Sam Feehan was yellow carded, a decision that proved significant. With the visitors down to 14, Pontypridd took advantage with some superb running rugby.
Full back Adam Thomas was the one to finish it off and with Humberstone nailing the touchline conversion, there were just three points in it after an entertaining first 40 minutes. For Cardiff, the converted try was compounded by the decision to yellow card lock Miles Normandale, meaning the Blue and Blacks started the second half with just 13 men.
Pontypridd failed to make the most of their numerical advantage as the second 40 got underway and when Cardiff were restored to a full complement, they moved further ahead. Ceiron Thomas' third penalty after 49 minutes restored a six point advantage and left Pontypridd chasing the game.
Initially there was no response from Dale McIntosh's side and with both sides bringing on replacements, there was a period of stalemate. Pontypridd aren't champions for no reason though and in a 10 minute purple patch, they recovered to move into the lead for the first time.
Replacement O'Connor got things started with Humberstone converting. Dicomidis then crossed for the third try, Alex Webber setting up the captain's score after breaking clear down the wing. When he was cynically blocked by Ceiron Thomas, the Cardiff fly half was incredibly lucky to avoid a yellow card. But from the resulting penalty, Pontypridd opted for the line-out with Dicomidis powering over. The conversion was missed but the home side were now ahead with just under 10 minutes to go.
In the end it proved to be enough as Cardiff's only opportunity came with a penalty from replacement Jack Maynard. The young fly half put his difficult kick wide though and it was Pontypridd who progressed to the British & Irish Cup pool stages.