Penalties from Geraint O'Driscoll either side of the interval and a late Rory Budina try were Newport's response leaving head coach Sven Cronk downbeat at the final whistle.
"The only crumb of comfort we could take from the game is our boys kept hammering away until the last minute when they were rewarded with a try," he said.
That unconverted touchdown was scored in the ninth minute of injury time by Budina as his side added to O'Driscoll's pair of penalties.
But Cardiff had long since scuppered home hopes with Thomas and Lewis getting the scoreboard moving. Hamilton's score only sealed the win with Ceiron Thomas converting all three tries.
Newport were still in contention at the interval but they crucially failed to take advantage of two spells where Cardiff received yellow cards.
Forwards Lewis Smout and Jonathon Edwards were both sin binned but there were few positives for Newport fans as Cardiff ended their Rodney Parade hoodoo.