By 6:00 pm (1700 GMT) calm had returned, with security forces patrolling the area around the mission. Armoured vehicles drove through the surrounding streets that were littered with debris.
President Moncef Marzouki in a television address denounced the attack on the embassy, calling it an unacceptable act against a friendly country.
"The violence that took place today outside the American embassy is totally unacceptable and is condemned," he said.
"One can maybe understand the anger of demonstrators and even share in it, but these young people have begun to commit acts of destruction, to set fire... to the embassy of a friendly country."
A health ministry spokesman told AFP that two people were killed during the clashes, adding that it was a provisional death toll.
He also spoke of "40 wounded, including 20 police officers."
Earlier, the ministry said three people had been killed and 28 wounded. Two of the wounded were reported to be in a critical condition.
Tunisian Prime Minister Hamadi Jebali, from the ruling Islamist party Ennahda, said he was "deeply troubled" by the attack on the embassy, according to the official TAP news agency, and cut short a two day break to return to Tunis.
The government appealed for calm, calling on "all citizens to respect the law and to express their positions peacefully when confronted with attacks on the sacred symbols and offenses against the prophet," TAP reported.
It also condemned the attack, saying those responsible would be brought to trial.
Tunisian imams and hardline Salafists had called Friday's protest outside the embassy to denounce a film mocking Islam posted on the Internet that has sparked anti-US protests across the Islamic world.
The amateur American-made video called "Innocence of Muslims," in which actors have strong American accents, portrays Muslims as immoral and gratuitously violent.
-- Burning cars and buildings --
More than 1,000 stone-throwing protesters had gathered outside the US embassy, shouting anti-US slogans including: "Obama! Obama! We are all Osama!" in reference to the slain Al-Qaeda mastermind Osama bin Laden.
They also waved the black Islamist flag and hurled insults at police, accusing them of "protecting" those who denigrate Islam. The police responded with firing tear gas and warning shots, as they tried to disperse the crowd.
But the demonstrators, acting aggressively, managed to clamber over one of the walls round the mission, near the car park where several vehicles had been set ablaze, an AFP photographer reported.
Petrol bombs, thought to have started the blaze, were thrown at a separate part of the embassy, causing another fire there.
And some of the protesters ransacked and torched an American school located just a few dozen metres (yards) from the embassy, TAP reported.
The police, backed by reinforcements from the army and the national guard, took nearly three hours to bring the situation under control, as they clashed repeatedly with the activists.
Security had been boosted around the US embassy in anticipation of violent protests, with a heavy deployment of riot police, soldiers and extra barbed wire, and checkpoints on nearby roads.
Some 300 Salafists had demonstrated there on Wednesday, and tried to break through the gates of the compound before being scattered by police firing tear gas.
The film behind the unrest, which also pokes fun at the Prophet Mohammed and touches on themes of paedophilia and homosexuality, also caused deadly violence in Sudan, Lebanon, and Yemen on Friday.
Earlier in the week US ambassador Chris Stevens and three other Americans were killed in neighbouring Libya, reportedly by a mob angered by the film.
Tunisia, where a mass uprising toppled former dictator Zine El Abidine Ben Ali in January last year and touched off the Arab Spring, has since witnessed numerous violent incidents linked to Islamist hardliners.
The opposition has strongly criticised the Islamist-led government for not doing enough to rein them in.