Megawati Sukarnoputri, the opposition icon who suffered a humiliating defeat in her bid for the presidency, was elected as Indonesia's new vice president today. The post was seen as a consolation prize that leaders hoped will calm her angry supporters and give the country a unified government to continue the march toward democracy.

The People's Consultative Assembly, the highest lawmaking body, chose Megawati over Muslim leader Hamzah Haz, 396 votes to 284. The vote came after two other strong contenders, military commander Gen. Wiranto and Akbar Tandjung, the head of the former ruling party Golkar, were persuaded to quit the race to avoid a divisive four-way contest.

The same assembly elected Abdurrahman Wahid, a frail and nearly blind Muslim cleric, as Indonesia's new president on Wednesday. His victory prompted supporters of Megawati, who had been considered the presidential front-runner, to rampage through Jakarta's streets, setting fires and throwing gasoline bombs at police. Two people died in that unrest.

The violence moved today to the resort island of Bali, where Megawati supporters erected barricades, threw stones at government buildings and set fire to the house of a government official. Megawati is the daughter of Indonesia's first president, Sukarno, who claimed to be half Balinese. Bali considers Megawati, 53, a favorite daughter.

Tonight, Jakarta's streets were calm as Megawati was elected vice president. The previous day's anger turned to celebration, as thousands of her boisterous supporters--waving flags and banners and beating drums--converged at a key downtown traffic circle that had become the site of their daily demonstrations.

When the result was announced, Megawati appeared subdued; she had to be coaxed from her seat to acknowledge the cheers of supporters who had packed the gallery of the assembly hall. She shook hands with the losing candidate and told reporters, "My first step is to do my best for the people of Indonesia."

Hours later, she beamed broadly during her swearing in. In a brief speech, she thanked former president B.J. Habibie for paving the way for the country's democratic transition. And she promised to work with Wahid "to stand up for all people in the service of the nation."

Various political leaders and analysts expressed hope that Megawati's election will help the country return to normalcy after more than 18 months of often-violent upheaval. Her Indonesian Democratic Party of Struggle, or PDI-P, won June's parliamentary election with 34 percent of the vote, but appeared to be locked out of power after Megawati lost the presidency.

The vice presidency has traditionally been mostly ceremonial with no formal power. But the job now is likely to take on added significance, because of Wahid's health and because Megawati's party controls about a third of the seats in the 500-member parliament, a separate legislative body from the 700-member assembly that elected the president and vice president. Her strength there gives her a stronger base of support than Wahid, whose party placed fourth in the June balloting. In addition, Wahid and Megawati, erstwhile friends and allies, are pillars of the democracy movement that opposed former president Suharto.

The nation was transfixed by the unscripted assembly sessions that elected the new leaders--the spectacle turned out to be the most open and democratic process in Indonesia's 54-year history. Many here said the week's dramatic events marked the end of Suharto's authoritarian era, which began in 1966.

"I think this is the beginning of a new era," said Jusuf Wanandi of the Center for Strategic and International Studies, a Jakarta-based research organization. "At last we have a good Muslim leader at the top after 54 years. We need our Muslim community to feel on a par with the others because they have always felt slighted and left behind."

"Essentially we have what they've been calling this grand coalition government," said Arian Ardie, a business consultant with the Columbus Group. "From a national unity standpoint, [Wahid and Megawati] are a very good combination," he said.

Others were more cautious. Some questioned the backroom maneuvering that allowed Wahid to beat out Megawati for the presidency. And many here questioned whether Wahid--who has suffered two debilitating strokes and is given to erratic statements--was up to the job of running the world's fourth-most-populous country.

Also, Megawati has been criticized for not having a firm grasp of complex policy issues, particularly economics. But, financial analysts were upbeat, saying Megawati's election represented a break from the past and should soon prompt a return of foreign investors spooked by the turmoil.

Muslim leader Amien Rais, who presided over the assembly session, said after Megawati's election: "This was a very beautiful game. It will make me able to sleep well tonight."

CAPTION: Megawati Sukarnoputri's supporters celebrate in gallery of the Indonesian parliament after she defeated Hamzah Haz for the vice presidency.

CAPTION: Megawati's role takes on greater meaning because of the new president's fragile health.