Hamas won a crushing victory in the Palestinian parliamentary elections as results yesterday showed it had swept away Fatah's 40-year monopoly of power, presenting a challenge to western policy towards "terrorist organisations".

Israel's acting prime minister, Ehud Olmert, joined the US, Britain and other countries in calling on the Islamist group, which has killed hundreds of people in suicide bombings, to renounce violence and its goal of destroying Israel if it wants international recognition.

"If a government led by Hamas or in which Hamas is a coalition partner is established, the Palestinian Authority will turn into an authority that supports terror," said Mr Olmert. "Israel and the world will ignore it and make it irrelevant."

The Palestinian president and veteran Fatah leader, Mahmoud Abbas, asked Hamas to form the next government after it unexpectedly won 76 seats in the 132-seat parliament in a stinging verdict on the corruption and mismanagement of Fatah's rule, and the failures of the peace process. Fatah won 43 seats.

Thousands of Hamas supporters took to the streets to celebrate, shooting in the air and handing out cakes. They clashed with Fatah activists in Ramallah as the Hamas flag was raised over the Palestinian parliament. Last night, hundreds of Fatah gunmen, angry at the result, fired rifles in the air in Gaza and called on Mr Abbas to resign.

The Hamas leader, Mahmoud al-Zahar, said his party was not interested in monopolising power and would begin immediate consultations with Fatah and smaller independent parties about forming a government of national unity. Some Fatah leaders said they would prefer to resolve the deep divisions within their own movement first, and watch Hamas try to deliver on its promises to end corruption, reform the Palestinian Authority and create a Palestinian state.

Although Hamas is banned as a terrorist organisation in the US and EU, President George Bush, in comments yesterday, did not rule out dealing with the new Palestinian administration. But it would have to renounce its past policies. "If your platform is the destruction of Israel, it means you're not a partner in peace, and we're interested in peace," he said.

Tony Blair said Hamas had won a powerful mandate, but must decide "between a path of democracy or a path of violence".

Hamas has said its year-long ceasefire demonstrates that it is committed to the political path. But last night, Dr Zahar said his organisation reserved the "right to resist" Israeli attacks on its activists and Palestinian territory. "We are under occupation. The Israelis continue aggression against our people: killing, detentions, demolitions. In order to stop this, we are entitled to self-defence by all means including using guns. If the Israelis stop their aggression, we will be committed to the quiet," he said.

Ismail Haniyeh, the Hamas leader in the new parliament, called on foreign governments to respect the election result. "'Don't be afraid' is our message to the outside world. Hamas is an aware, mature and politically-open movement," he said.

Mr Bush implicitly acknowledged that it would be difficult to shun a movement that has won a fair election at a time when the west is pressing other Arab countries to democratise. He said the result was a "wake-up call" for the old Palestinian leadership.

Israeli analysts say a Hamas-controlled Palestinian government will destroy any prospect of a negotiated settlement and encourage Israel to pursue a unilateral strategy aimed at marking out its final borders and imposing them on Palestinians.