Wednesday, October 20, 1999 Published at 13:55 GMT 14:55 UK
Indonesian election triggers violence
A Megawati supporter vents his anger after her defeat
A moderate Muslim leader has been sworn in as the new president of Indonesia following a shock parliamentary vote which has sparked violence in the capital Jakarta.
Within minutes of the result being announced, a car bomb exploded near parliament as an estimated 10,000 Megawati supporters marched on police lines.
The bomb followed another blast earlier in the day. At least eight people have been hurt in the two explosions.
Indonesia's politically powerful military has welcomed the election of Mr Wahid.
Military chief General Wiranto said he was willing to serve as his vice-president if accepted by all factions in the assembly.
The atmosphere in parliament was electric as each vote was individually recorded, with Megawati and Mr Wahid neck-and-neck for most of the count.
Megawati stood silent and apparently close to tears as the result was announced.
Immediately after the announcement, Mr Wahid promised to try to restore order in the streets.
Megawati conceded victory and called for unity.
"For the sake of the integrity of the nation, I urge all Indonesians to understand the situation," she said.
Mr Wahid - better known as Gus Dur - founded Indonesia's largest Muslim party, the National Awakening Party, which came third in the parliamentary elections earlier this year.
He was one of only two candidates standing for the presidency, after the former ruling party Golkar decided not to field a candidate in place of President Habibie.
The BBC Jakarta correspondent, Jonathan Head, says that it was probably the votes of Golkar MPs which were crucial for Mr Wahid.
He also won the support of the Muslim-based Crescent and Star Party after Muslim protesters had warned that they could not accept a woman as president.
Share prices in Jakarta initially rose by as much as 10% in anticipation of a victory for Megawati, but lost most of their gains after the result came through.
Mr Wahid, 59, is in fragile health with very poor eyesight, but he has long been seen as a potent force in Indonesian politics.
He gained increased prestige for his opposition to former President Suharto, but since Suharto's fall from power, Mr Wahid has counselled conciliation.
Mr Wahid is a revered and moderate Islamic leader, known for his religious tolerance and belief in secular government.
He has backed a referendum on independence for the restive province of Aceh in northern Sumatra, which would be likely to put him at odds with the powerful military.
After parliament rejected his account of his record in office, he announced his withdrawal from the presidential race, telling a news conference: "I believe that many sons and daughters of Indonesia can do the job better than I have done."
"I'm happy that democracy has started in Indonesia, and I hope this will continue whoever the new president is," he said.
Mr Habibie has also been tainted by his closeness to the discredited former President Suharto.