The two men became the first world leaders to travel to the country since rebel forces seized the capital and ousted Moammar Gadhafi.
Both Britain and France led international support for the rebellion.
Sarkozy and Cameron each congratulated the National Transitional Council, the closest thing Libya now has to a functioning government.
"This was your revolution, not our revolution. It was those brave people in Misrata, in Benghazi, in Brega, in Zlitan, in Tripoli, in the Nafusa Mountains, who were incredibly brave in removing the dreadful dictatorship of Ghadafi," said Cameron.
Both leaders said Ghadafi, whose whereabouts are still unknown, should be brought to justice. Cameron told the fugitive Libyan leader and his backers, "It is over. Give up."
Cameron pledged the NATO mission would continue as Gadhafi loyalists are still battling revolutionary forces on three fronts in central and southern Libya.
The Associated Press contributed to this story.