THE VIOLENT street demonstrations that greeted the election of a new president of Indonesia may give an impression that reform has failed, but that is too simplistic a reading. Young, pro-reform backers of the most prominent pro-reform candidate, Megawati Sukarnoputri, took to the streets after an electoral college rejected her candidacy. The surprise winner and new president of the world's fourth most populous nation, Abdurrahman Wahid, is -- like his defeated rival -- a political leader with a complicated history, but one that entitles him as much as her to a reform mantle.

It's true that Ms. Megawati, daughter of Indonesia's post-independence leader, Sukarno, is the favorite of many of the urban poor. It's true also that this experiment in democracy was only partly democratic; most of the 700 electors who voted yesterday were chosen by the people, but a large minority was appointed by the military brass and other elites -- and those appointed electors seem to have sided with Mr. Wahid. And Mr. Wahid's supporters will not have endeared themselves to human rights supporters with their campaign suggestion that Indonesia was not ready for a woman leader.

But Ms. Megawati's loss results more from her own failings than from the system's. Although her party scored best in national elections in June, she failed to form the necessary political coalitions. Her passivity and lack of clear positions not only hurt her chances but also raised legitimate doubts about what kind of president she would be. This is how democratic politics is supposed to work.

Moreover, during the last decades of authoritarian rule, Mr. Wahid worked within the system but often showed more courage and independence than his rival. He heads Indonesia's largest Muslim organization, with 30 million claimed followers, but he has spoken out clearly for tolerance and against a mixing of religion and politics. This is crucial in a country with sizable Christian and Hindu minorities and an ethnic Chinese minority that often has been persecuted. Mr. Wahid angered some pro-reform activists with his embrace of moderation, but he has committed himself to economic reform and has been relatively open to the aspirations for autonomy in East Timor and other corners of the Indonesian archipelago.

It's not yet clear that Mr. Wahid's election promises the stability that Indonesia needs for economic recovery -- and that other countries are so eager to see in this strategically crucial nation. Ms. Megawati's followers may not accept the legitimacy of his election. And though he is only 59 years old, the new president is said to be in poor health after surviving two strokes.

East Timor poses an early test for Mr. Wahid. The same legislative body that elected him also voted to let that former colony slip free of Indonesian rule and evolve toward independence. But this is not the end of Indonesia's obligations, after its army conducted or condoned terrible violence against the people of East Timor. Indonesia is still holding hundreds of thousands of East Timorese refugees who must be permitted to go home; the country also has promised to conduct a rigorous investigation of the violence. These must be among the new government's top priorities.