JAKARTA, Indonesia -- The most serious rioting in decades erupted yesterday in downtown Jakarta, with anti-government protesters hurling rocks and setting fire to buses, cars and several office buildings, then fleeing wildly as police and soldiers charged at them with bamboo canes.

The rapid spread of the rioting and the anger of the people in the streets seemed to take authorities by surprise and raised questions about the government's ability to control popular protest as the country enters a contentious pre-election period.

Scores of people were wounded. An independent legal aid society said at least three and up to seven people had been killed, but there was no confirmation. The violence continued into the night; at least three fires raged out of control as rioters blocked fire trucks.

During his 30-year rule, President Suharto has not allowed any serious political opposition, silencing his critics, keeping tight control on news organizations and offering little outlet for grievances here in the world's fourth-most-populous country.

The violence yesterday was touched off when police raided the headquarters of the opposition Indonesian Democratic Party early in the morning and forcibly evicted about 150 supporters of Megawati Sukarnoputri, who has emerged in recent months as a symbol of opposition to Suharto.

Megawati's supporters had been occupying the headquarters for about a month, vowing to keep out members of a party faction backed by the government.

Although most political analysts say Megawati does not present a real challenge to Suharto's power, her outspoken opposition is a sharp break with Indonesia's carefully controlled system of opposition by consensus.

Suharto, who like many Indonesians uses one name, has presided over a sharp rise in living standards in his decades in office, and it remained unclear just who was involved in yesterday's violence or how much they represent the mood of the nation.

What began as a political protest yesterday morning seemed to degenerate into lawless violence, with extremist groups taking advantage of the chaos.

Few people here doubt that Suharto will win re-election if he does run for another term in 1998, after parliamentary elections next year. But while even his critics acknowledge that he has brought growth and increasing prosperity to this country of 190 million people, even some of his own ministers say privately that the time has come for a change at the top.

"I believe Megawati now has become a symbol of protest, a rallying point for many people who feel their aspirations cannot be channeled through the present system," said Soedjati Djawandono, a political scientist with the Center for Strategic and International Studies.

Megawati, 49, is the daughter of Indonesia's founder, Sukarno, who is still revered by many people three decades after he lost power to Suharto. Sukarno died under house arrest in 1970.

As they faced police lines, protesters chanted Megawati's name and shouted grievances about repressive military tactics, including the suppression of opposition in East Timor and Irian Jaya.

In words that were shocking in the normally low-key oratory of Indonesian politics, some shouted: "The military are killers!" and "Hang Suharto!"

Yesterday's confrontation had been brewing for weeks. Just over a month ago, in an effort to neutralize Megawati's growing popularity, the government engineered her ouster as head of her party, backing a rump party congress that replaced her with her predecessor, Suryadi, a man who subscribes to the president's philosophy of opposition by consensus.

But Megawati's supporters refused to leave the party's headquarters.

The long-awaited raid on the office came at 7 a.m. yesterday, when men disguised in the red shirts and headbands of Megawati's supporters attacked the one-story building with a barrage of rocks. Two hours later, together with police, they charged the building.