Abdurrahman Wahid, a Muslim leader who is frail and nearly blind, was elected Indonesia's fourth president Wednesday in a surprising vote by the People's Consultative Assembly. He rode to victory on the strength of an unlikely coalition of Islamic conservatives and the long-ruling Golkar party of former president Suharto.

Wahid, 59, won a two-way race against his onetime ally, Megawati Sukarnoputri -- a popular opposition leader and the daughter of Indonesia's founding president, Sukarno -- who had been considered the front-runner after her party won parliamentary elections in June.

Immediately after the presidential vote, thousands of Megawati's bitterly disappointed supporters took to the streets of the capital in angry protest, hurling molotov cocktails and setting fire to the Jakarta Convention Center.

As the rioting indicated, Wahid's first challenge will be to return the world's fourth-most-populous country to normal after a year and a half of political and economic upheaval, including the ouster of Suharto and a massive banking scandal that consumed the final weeks in office of Wahid's interim predecessor, B.J. Habibie.

His first step was to reach out to Megawati, with his party nominating her as vice president. But three other candidates were also nominated, representing the other factions that helped Wahid win power: the military, the long-ruling Golkar party and another Muslim party. With so many candidates, this morning's assembly session to choose a vice president was postponed for several hours while political leaders tried to narrow the field.

Restoring stability will not be easy for Wahid and whoever becomes his vice president. His Islamic supporters may see his election as a chance to impose more religion on the secular politics of Indonesia -- the world's largest Muslim country -- and he must deal with a military establishment that remains powerful in this nascent democracy. In addition, he will be working without a firm base in the newly assertive legislature; his National Awakening Party placed fourth in the June elections, and on Wednesday he needed votes from the discredited Golkar party to win the presidency.

Wahid leads the 30-million-member Nahdlatul Ulama, a rurally based, traditionalist Muslim social group. He is known as a canny political operator who managed to be a critic of Suharto -- who ruled for 32 years before massive protests forced him to step down in May 1998 -- while maintaining good relations with Suharto's daughter, Siti Hardianti Rukmana, or "Tutut." He is known, too, as something of an enigma. He collects jokes, for instance, and recordings of Beethoven's 9th Symphony. He loves Western classical music in general but is also a rock fan whose favorite all-time hit is Janis Joplin's "Me and Bobby McGee."

But the swearing-in provided disturbing images. To deliver his acceptance speech, Wahid had to be helped to the stage and to the podium by two aides clutching his arms. And when the time came to sign his name and shake hands, his hands had to be guided by aides.

Both Wahid, who was sworn in Wednesday night, and Megawati urged her followers to respect the result, but the street violence continued for hours, with police firing tear gas and rubber bullets at protesters who set fires, looted shops and vandalized cars. A device tossed into a car exploded during the melee, killing one person and injuring several others near the assembly hall where the presidential vote was held. Another explosion occurred after dark on a toll road near the assembly building. Earlier, a smaller blast at a downtown traffic circle packed with Megawati supporters injured four people.

Wahid -- known here as "Gus Dur," a combination of an Indonesian honorific and a diminutive of his given name -- used his acceptance speech to urge all factions to "put aside our differences." Referring to the political, religious and ethnic divisions that have riven this vast archipelago over the last 17 months, he said: "At this time, we are torn apart by profound misunderstandings." He also offered his "deepest appreciation to my good friend" Megawati Sukarnoputri, who sat stone-faced through the brief installment ceremony.

Wahid won 373 votes in the 700-member assembly, compared to 313 for Megawati, with five members abstaining and no votes from nine others from East Timor -- a breakaway territory whose recent vote for independence was ratified by the assembly only hours before the presidential ballot. It was a surprisingly decisive win in a contest that had been expected to be much closer, and it demonstrated how, in the hours and minutes before the vote, Megawati's support among major factions eroded in the divided assembly.

Despite the public violence, the disorder seemed likely to be limited because Wahid is a popular and respected member of the democratic reform camp championed by Megawati. He has appeared in public often with Megawati, most recently traveling with her to East Java where they visited their fathers' graves.

The United States and Asian governments welcomed Wahid's election, but some analysts noted concerns over his health. Wahid has suffered two debilitating strokes and has undergone corrective eye surgery in Salt Lake City but still suffers from severely impaired vision. Recently, he had been receiving regular vitamin injections at a local hospital. His frailty raised immediate questions about whether he will be able to confront the rigors of the presidency for a full five-year term.

"Maybe this is the first time in the world, maybe it's in the Guinness book of world records, that a blind man is president," one of Megawati's aides said bitterly after the vote.

The U.S. assistant secretary of state for East Asian and Pacific affairs, Stanley Roth, called Wahid a man Washington can work with. But in an apparent reference to the public protests, he added: "We have to see how the political process plays out in Indonesia itself. . . . The next 24 hours are quite critical."

Australian Prime Minister John Howard said his government is willing to repair strained ties with Indonesia and form a solid relationship with the new leader. "I can assure Mr. Wahid of the goodwill of the Australian government . . . and our support as he faces the huge challenge of leading Indonesia through political transition and achieving economic recovery," Howard said in a statement.

Australia's supportive stance on East Timor's bid for self-determination and its role in leading the multinational force sent to the territory under U.N. mandate to quell anti-independence violence there have strained relations between the two countries.

The state of Wahid's health also focused attention on who will become vice president. Megawati and her aides had earlier said she would not accept the No. 2 post. But others urged Megawati to take the vice presidency to help heal political divisions and calm her angry supporters. She had no immediate comment on the nomination from Wahid's party.

The other candidates for vice president are Golkar party leader Akbar Tandjung, who threw his support behind Wahid, ensuring his victory; the commander of the armed forces, Gen. Wiranto; and Hamzah Haz, leader of the United Development Party, the third-largest in the assembly. Earlier this week, Wiranto turned down an offer from Habibie, the unpopular incumbent, to be his running mate, but the armed forces command welcomed Wahid's election on Wednesday.

Until Wednesday, Wahid had been considered a potential spoiler in the presidential race rather than a serious candidate. But that was before Habibie unexpectedly withdrew from the race, hours after the assembly rejected a speech in which he defended his 17-month tenure, effectively casting a vote of no confidence in his administration. Another candidate, Muslim leader Yusril Ihza Mahendra, withdrew as well, leaving the contest to Wahid and Megawati.

"We were taken by surprise," said Subagio Anam, a Megawati ally and member of parliament. "In the place of Habibie, we expected somebody else from Golkar. . . We thought Gus Dur was only playing a game in running for the presidency."

Megawati, widely accused of squandering her party's victory in the June parliamentary elections by refusing to negotiate patronage with other parties, appeared gracious in defeat. "For the unity of the nation, I ask all Indonesians to accept this outcome," she said.

But her supporters were angry, and many said they felt betrayed by Wahid, who had been a nominal Megawati ally, encouraged her to run for the presidency and promised to back her.

"I feel disappointed and bitter," said Laksamana Sukardi, the treasurer of Megawati's party and a top adviser. "We've been working this out for quite some time, and we go through a democratic process, building the party, building the constituencies . . . unlike other candidates who just appear."

An Islamic Moderate

* Born 1940 in Jombang, eastern Java, into a family of Islamic scholars who established and ran seminaries. Both parents were active in the nationalist movement against Dutch colonial rule.

* Studied in various traditional Islamic boarding schools and at Al-Azhar Islamic University in Cairo and the University of Baghdad. During a study tour in Canada, he was exposed to Western thought, literature and music.

* Married in 1968 and has four children.

* Held teaching positions at several Indonesian universities and Islamic boarding schools between 1972 and 1978.

* Elected general chairman of the Nahdlatul Ulama, the world's largest Muslim organization with 30 million members, in 1984.

* Believes in separation of religion and politics. While he favors Islamic education, he has said, "I am trying to humanize, liberalize and democratize the interpretation of Islam." He strongly advocates national reconciliation of Indonesia's many ethnic and regional minority groups.

* Is outspoken. Wahid said about his predecessor, B.J. Habibie: He "doesn't have political sense, or a sense of politics." And about opposition leader Megawati Sukarnoputri: "Although she is stupid, she loves people."

SOURCES: staff and wire reports