Security forces put a cordon around the Pakistani capital and made hundreds of arrests, before using tear gas and gunfire to quash a banned protest Sunday against cartoons of the Prophet Muhammad, witnesses and officials said. Police detained several lawmakers and Islamist leaders during raids in three cities ahead of the planned rally in Islamabad, where a few hundred demonstrators clashed with security forces for three hours, hurling stones and injuring at least two policemen. Denmark, where the cartoons were first published in September, temporarily withdrew its ambassador from Islamabad Sunday in the midst of the tension, the Danish foreign ministry said in a statement. Opposition leader Maulana Fazlur Rahman, who denounced a government ban on the demonstration as unconstitutional, was granted 11th-hour permission to lead a small rally of eight other opposition lawmakers and about 25 of their supporters through a square in the city center. They chanted "God is great!" and "Any friend of America is a traitor," as they marched. Authorities mounted roadblocks around the capital and declared they would arrest anyone joining a gathering of more than five people to prevent the rally called by Rahman's six-party hardline Islamic coalition, Mutahida Majlis-e-Amal (MMA) or United Action Forum. Paramilitary troops patrolled in pickup trucks with mounted machine guns, and soldiers behind sand bag bunkers guarded government buildings. Qazi Hussain Ahmad, another top MMA leader, was placed under house arrest in Lahore, while other senior leaders in Islamabad were either arrested or asked not to leave their homes, police said. Police fired tear gas and at least one gun shot to disperse about 100 supporters who tried to reach the same city square as Rahman, an Associated Press reporter saw. More gunshots were heard later in the city, but it wasn't clear who fired them. The AP reporter saw two injured police, one bleeding from his head, and several injured protesters. A second wave of protesters, pelting police with rocks, managed to reach the square and 500 clashed with police there for three hours before dispersing, leaving the ground littered with rocks and spent tear gas shells, the reporter said. There was no apparent damage to surrounding property. A police officer, speaking on condition of anonymity because he wasn't authorized to speak to media, said about 25 of the protesters were arrested. Interior Minister Aftab Khan Sherpao said police used tear gas not gunfire. Police raided homes and offices in Islamabad, neighboring Rawalpindi and Lahore overnight to round up hundreds of people they suspected intended to join the rally. Officials said they had arrested 140 people in Rawalpindi, including some lawmakers, and at least 150 in Lahore, and others in Islamabad. "These people could create problems of law and order," said Chaudhry Shafqaat Ahmed, chief investigator of Lahore police. Rahman, the leader of the opposition in Pakistan's parliament, told reporters, "The entire Muslim world has risen in protests against the unholy effort to insult the prophet in Denmark and other countries. We are with the entire Muslim world." Police blocked about 1,500 MMA supporters from reaching Islamabad from the northwestern city of Peshawar, an MMA stronghold, by putting shipping containers and sand bags on a bridge along the highway, about 100 kilometers (62 miles) west of the capital, said Mohammed Iqbal, a spokesman for Jamaat-e-Islami, Pakistan's largest Islamic group and a key member of the religious alliance. Elsewhere in Pakistan, about 600 people staged a protest in Chaman, a town near the Afghan border, burning Danish flags and an effigy of Danish prime minister. Pakistani intelligence officials have said militants from outlawed extremist groups have been stirring up the recent violence at protests, that killed five people last week. Authorities have banned demonstrations in the whole of the eastern province of Punjab where Islamabad is located.