Wednesday, October 20, 1999 Published at 13:26 GMT 14:26 UK
Analysis: Indonesia faces more uncertainty
Mr Wahid (centre) appealed for calm after the result
By regional analyst Olivia Stewart
In a race that remained uncertain until the very last minute, an ailing Muslim cleric has beaten a popular female opposition leader to become the president of Indonesia, the world's fourth most populous nation.
Mr Wahid will succeed the deeply unpopular President Habibie who withdrew his bid to retain office after failing to gain the endorsement of the People's Consultative Assembly for his brief but chaotic period as head of state.
The surprise result in Indonesia's first free presidential race in over 40 years was hailed as a victory for democracy - but it leaves many questions still to be resolved.
The task that now falls to Abdurrahman Wahid - popularly known as Gus Dur - is a challenging one.
In recent years, Indonesia has been wracked by violence, political instability and economic chaos.
However, many observers have hailed him as a good compromise candidate - and one of the few figures capable of drawing together a divided nation.
As leader of the 30-million-strong Muslim organisation Nahdlatul Ulama and nominee of a number of Muslim parties, Mr Wahid has a huge constituency amongst Indonesia's Muslims, many of whom abhorred the possibility of a female president.
However, Mr Wahid's support for secular government and calls for tolerance of minorities should help reassure Indonesia's non-Muslims.
However, questions remain over the state of the new president's health. Mr Wahid, 59, has already suffered two strokes and is virtually blind.
In addition, some have criticised his political manoeuvring as a sign that he is lacking in principle.
Others have pointed to his lack of economic expertise at a time when Indonesia's fragile economy is in need of careful guidance.
Mr Wahid will also have to contend with the anger of millions of disappointed Megawati supporters.
Widely adored as daughter of Indonesia's founding president Sukarno, Megawati had been seen by many as a symbol of democratic change in Indonesia.
Her followers, clad in red and black, had already started to gather in Jakarta to celebrate what seemed to be her certain victory when news of the actual result emerged.
What she will expect in return - and indeed what other political deals were brokered to ensure Mr Wahid's victory - remain unclear.
The new president does appear to have won the votes of at least some members of outgoing president Habibie's Golkar party.
Wahid will also have to proceed with an eye to Indonesia's powerful military.
Despite increasing calls from the Indonesian public for the army to stay in its barracks, military leaders are likely to demand some pay-off for standing behind his presidency.
Moreover, nominations for the vice presidency take place later on Wednesday, with voting in parliament on Thursday.
Only in the coming days and weeks will the shape and colour of the new administration become clear.
Despite his reputation as a political survivor, it could take all Abdurrahman Wahid's political agility to balance the conflicting demands on Indonesia's new head of state.