Since the founding of the Indonesian republic a half century ago, the armed forces have been the power behind the power -- the preeminent force in the nation's political and social life whose dominant role was enshrined in a doctrine known as "dual function."

From the era of the late President Sukarno's "guided democracy," military officers served as cabinet ministers, governors, and, later, as members of parliament. They ran sprawling government departments and the smallest villages. And for most of the past three decades, the armed forces served as the major pillar beneath the New Order regime of Sukarno's successor, Suharto, who was himself a senior army general.

Now as Indonesia enters a more open era of democratic politics -- a transition delayed by an excruciatingly slow vote-counting process following the June 7 elections -- the armed forces are grappling with an unaccustomed political role. Rather than being the unassailable kingmakers, the armed forces have become just one force among many -- and not necessarily the dominant one.

The military suddenly is vying for influence with political parties, grass-roots organizations, students, a newly unshackled press and a populace that has experienced its first free election in 44 years.

"In the past, whatever they wanted was done," said Harold Crouch, an analyst of the Indonesian military at Australian National University. "Now they are going to have to bargain, to negotiate, to compromise."

To be sure, the armed forces still wield considerable clout. Thirty-eight seats in the new 500-member parliament are reserved for military appointees, and the military may get even more in the expanded, 700-member super-legislature that will convene to choose Indonesia's next president this year. That expanded body will include 135 representatives from Indonesia's 27 provinces, and military officers may be among them, since some hold appointed seats in provincial legislatures.

With its 38-plus seats, the armed forces could be the swing vote if the legislature deadlocks over incumbent President B.J. Habibie and opposition leader Megawati Sukarnoputri. Unofficial results so far show Megawati's Indonesian Democratic Party of Struggle, or PDI-P, still far ahead in the crowded field with about 36 percent of the vote, and Golkar, the ruling party, a distant second with about 20 percent.

But the final results are likely to leave Megawati far short of a majority, and Golkar officials are already working behind the scenes trying to woo smaller, Islamic parties into a majority coalition. They have found some sympathy, because of the argument -- heard with increasing frequency here in the past week -- that Megawati is anti-Islam and that the world's most populous Muslim nation should not have a female president.

The armed forces leadership has remained quiet as the political bargaining has intensified. To some, that means the military leaders are preserving their options, waiting to see which of the two camps emerges stronger. But to others, the silence so far might be a sign that the armed forces face what they see as two unpalatable choices.

Salim Said, a political scientist and military analyst who teaches at the army staff college in Bandung, noted that if the military chooses Habibie, who succeeded Suharto, "they will be accused of supporting the status quo. If they choose Megawati, people will say they are against Islam. So they are in a very difficult position."

There has been much speculation, particularly among Jakarta's elite and in the press, that the armed forces commander, Gen. Wiranto, could emerge as a compromise choice for president if it is necessary to break a Habibie-Megawati deadlock. But Salim, and others, said that outcome is still unlikely, because Wiranto would be considered unacceptable by supporters of reform, particularly the students whose unrelenting protests brought about the fall of Suharto last year.

While credited with launching some badly needed reforms in the armed forces -- including reducing their political role -- Wiranto is still seen by many as a holdover from the discredited Suharto government who is shielding the former president from corruption investigations.

Under Wiranto, the military has been involved in repeated human rights abuses, including massacres of civilians, in the restive province of Aceh. The army also is tacitly backing militias waging a campaign of terror in East Timor province, where an independence vote is set for August.

Talk show host Wimar Witoelar, a political analyst, said the military's battered prestige might be one reason the leadership would ultimately back Megawati over Habibie in a close contest: to restore the armed forces' image with the public. "The minute they declare for Megawati, they will be showered with flowers," Witoelar said.

Others have noted that Megawati's party is closer than Golkar to the military's positions on many issues. For example, the military is believed to favor Megawati's position against independence for East Timor, against federalism, and in favor of a unitary state with a strong central government. Also, as Crouch said, "they feel they can manipulate Megawati to some extent."

The idea of the powerful armed forces taking a sidelined role in the political bargaining is remarkable enough, and further evidence of the breathtaking changes that have swept Indonesia. But Wiranto seemed to recognize those changes early, and has been moving to bring the armed forces into line with Indonesia's new political reality.

At least 4,000 officers in nonmilitary jobs have been told to quit, retire, or give up outside jobs and return to duty. The military agreed to have its seats in the legislature cut to 38 from 75. "The writing is clearly on the wall that this is the beginning of the end for the military in these political roles," said a Western diplomat who analyzes military affairs. "And within the ranks of the military, there are a lot of officers who are unhappy."