Lebanese demonstrators have set the Danish embassy in Beirut on fire in protest at the publication of cartoons depicting the Prophet Muhammad.

Thousands of people attended a rally and clashes broke out with security forces sent to protect the building.

Lebanese leaders condemned the attack and Interior Minister Hassan Sabeh announced his resignation.

The violence came a day after mobs in neighbouring Syria torched the Danish and Norwegian embassies in Damascus.

Danish Foreign Minister Per Stig Moeller has called for a calming of tensions.

"It is a critical situation and it is very serious," he told Danish public radio.

Denmark urged its citizens to leave Lebanon as soon as possible.

The cartoons first appeared in a Danish newspaper in September and caused outrage among Muslims, who consider any images of Muhammad offensive.

One of the cartoons shows Muhammad wearing a bomb-shaped turban.

Newspapers across Europe have republished the pictures in recent days, saying they are defending freedom of expression.

'Respect our religion'

Huge crowds attended Sunday's protest in the Christian neighbourhood where the Danish embassy is located.

The protest started out peacefully, but turned violent after Islamic extremists tried to break though security barriers protecting the building.

"We have a right to defend our prophet," one protester told the BBC.

"They should have respected our religion," said another.

Some 2,000 riot police and army troops fired tear gas and water cannons to disperse the crowd and fired their weapons into the air.

But smoke was later seen rising from the building, which also houses commercial offices, after demonstrators broke into it.

The building was believed to be unoccupied at the time.

Some protesters threw stones at the security forces and burned Danish flags. A nearby church and other property in the neighbourhood were also attacked.

Security officials said at least 18 people were injured, AP news agency reported.

'Inexcusable' actions

Some Muslim clerics helped to persuade the crowd to disperse as the violence died down, the BBC's Jim Muir reports from the scene.

Lebanon's most prominent Sunni leader, Saad al-Hariri, vowed to track down and prosecute those involved in the attacks.

"We tell our Christian brothers that any stone thrown against a house or a car was an insult to Muslims," he said from Paris.

In other developments:

* Hundreds of people rally in Afghanistan in protest at the cartoons * Iraq's transport ministry freezes contracts with Denmark and Norway * Iran recalls its ambassador to Denmark * An Iraqi militant group in the insurgent stronghold of Ramadi calls for attacks on Danish and non-Muslim targets in Iraq * Two tabloid editors in Jordan, arrested after publishing some of the cartoons, plead not guilty to charges of insulting religion.

Denmark and Norway have condemned Syria for failing to stop Saturday's attacks in Damascus and urged their citizens to leave the country.

"The principle of diplomatic relations is that diplomats can work safely and the fact that this has been broken is extremely serious," Norwegian Foreign Minister Jonas Gahr Stoere told a news conference in Oslo.

The US also criticised Syria's approach, saying it was "inexcusable" for such damage to be inflicted on diplomatic missions.