President B.J. Habibie abandoned his campaign to remain in office today, hours after Indonesia's highest lawmaking body repudiated him in dramatic fashion and also voted to relinquish the national claim to East Timor.

The actions by the People's Consultative Assembly came after a night of tension, high emotion and considerable confusion. One opened the way for East Timor to become a U.N. protectorate, pending full independence; the other demonstrated emphatically that Habibie did not have enough support to win today's presidential election in the assembly.

Habibie's withdrawal and his Golkar party's decision not to nominate another candidate created a confusing two-way race between the main opposition figure, Megawati Sukarnoputri, and Muslim cleric Abdurrahman Wahid, leader of Nahdlatul Ulama, the world's largest Islamic organization.

As the votes were being counted at midday, Megawati's aides were voicing fears that she had lost. It appeared that the Golkar party was aligning itself with a strong Islamic bloc in the assembly that was determined to prevent a secular woman from becoming president of the world's most populous Muslim country.

The action on East Timor came with no debate and passed by acclamation, a quiet and swift acceptance of the results of an Aug. 30 referendum in which the East Timorese overwhelmingly voted to secede from Indonesia. Despite the subsequent explosion of violence in East Timor by anti-independence militia groups, the assembly's acquiescence had been widely expected since the Indonesian military ceded practical control of the territory to an Australian-led, U.N.-backed international peacekeeping force three weeks ago.

More surprising was the assembly's vote to reject Habibie's so-called "accountability speech," which was basically the president's defense of his stormy 17 months in office. Habibie had made an impassioned appeal for the 700 assembly members to endorse his speech -- at one point apologizing for "shortcomings and incompetencies" -- but in the end it was rejected, 355 to 322, with 13 members abstaining or casting invalid ballots.

The accountability speech is a tradition here, much like the State of the Union address in the United States, but it has taken on added significance since Indonesia tossed off its authoritarian past last year and began to embrace democracy. Under former president Suharto, who ruled Indonesia from 1966 until last year, the speech was routinely ratified, but this assembly is far more assertive than previous ones.

The vote was considered a key test of strength in the assembly in advance of the crucial vote later today to select the next president. The margin was narrow -- just 33 votes -- but it indicated Habibie's foes in the democratic reform camp were in control of the session and had enough votes to oust him.

When the vote result was read, just after midnight, some anti-Habibie assembly members cheered and thrust their fists in the air. Habibie supporters appeared distraught, some trying to rub the fatigue from their faces following the marathon session. But the loudest applause came from the spectator gallery, where Indonesian journalists -- many of whom have been critical of Habibie -- broke into cheers and applause. Shortly afterward, Habibie's party announced that he would withdraw his bid to remain in office, and he later held a news conference to deliver the message in person.

"I announce my withdrawal from the presidential nomination, and I believe that many sons and daughters of Indonesia can do the job better than I have done," he said.

Habibie's withdrawal initially cheered supporters of Megawati, daughter of Sukarno, founder of modern Indonesia. They took to the streets in central Jakarta, but the celebration was dampened when fireworks exploded in a flower pot, police said, injuring several people.

The emotion of the vote on Habibie nearly obscured the following decision concerning East Timor. The speaker of the assembly ruled that no formal vote was needed on the matter because all 11 factions in the assembly -- political parties and representatives of sectors of society -- had already endorsed a committee proposal to ratify the referendum result and rescind a 1976 law annexing East Timor as an Indonesian province.

The vote allows for the remaining 1,500 Indonesian troops in East Timor to be withdrawn and for security responsibilities to pass to the 7,000 international troops.

East Timor's resistance leader and its likely first president, Xanana Gusmao, had said this week in Australia that he would not return to his homeland until after the Indonesian assembly voted officially to allow East Timor to become independent.