Prime Minister Prem Tinsulanond swept back into power this morning with a near-bloodless countercoup that forced his political rival to flee and led to the arrests of many of the Army officers who tried to seize control of the government two days earlier.

While Prem, 60, a general who also heads the Army, emerged stronger by crushing the coup attempt, analysts here believe that his newly formed government coalition remains fragile. Prem has not yet returned to the capital from his refuge in Korat to the northeast.

His victory in the attempted coup brings Prem breathing space to try new Cabinet shuffles to accommodate the fractious civilian and military politicians and curb inflation, which at 20 percent is the highest in Southeast Asia.

It was the perceived weakness of Prem's new Cabinet, formed last month, that appeared to have given his military rivals the confidence to try to take over in a lightning grab of government facilities here Wednesday.

Prem, however, raced off to Korat, where he gathered the support of most of the military, including three of the four major Army commands, and -- even more important -- of the royal family that accompanied him. The generally nonpolitical king, Bhumibol Adulyadej, not only is the constitutional head of state but is much revered.

Besides the military and royal support, Prem also had a radio transmitter at his disposal in Korat. Although weak, it was enough to give the people in Bangkok the word that the new "revolutionary council" formed by Gen. Sant Chitpatima, was not in total control and that Prem had royal support.

When Prem made his move around dawn today, dispatching thousands of loyal troops to Bangkok by plane and truck, the capital was ready.

Many of the rebel troops, wearing pink bands on their right arm, greeted the loyalists with handshakes instead of gunfire.

There were two reported deaths, a civilian and a rebel soldier who were shot when one group held out against Prem's forces as they moved on the royal palace.

Sant, 59, once a closed political ally of Prem's, was reported to have fled the city in a helicopter and is believed to have crossed the southern border to take refuge in Burma.

One of his supporters, the commander of the First Army region that includes Bangkok, Gen. Vasin Israngkul Na Ayuttaya, was arrested today along with a large number of the colonels who formed the bulk of Sant's supporters.

Prem was reported tonight to be in Korat talking to many of the young officers to determine whether they will be arrested, thrown out of the military or allowed to remain.

In a television address believed to have been taped at Korat, Prem offered an amnesty to ordinary soldiers who went along with the coup attempt. He said they merely obeyed the orders of their commanders without knowing what they were doing.

"I will accord justice to all and there should be no concern about this. Rather they (the soldiers) should forget the whole situation and look toward the future in which we should jointly serve," said the handsome, silver-haired Prem, dressed in military fatigues.

It is uncertain when Prem will return to Bangkok and whether he will make it a triumphant occasion, with the royal family at his side to end any lingering doubt that they fully support him. Some Thai sources believe Prem will slip quietly into the city to give his newly resurrected government a business-as-usual appearance.

It is hard to determine the roots of Sant's coup attempt. It is known, however, that he became annoyed last year when Prem refused to quit as Army commander when he reached the mandatory retirement age of 60. Sant, the deputy commander, was scheduled to replace Prem.

The leaders of the short-lived coup, in their manifestoes, had taken a highly moralistic tone, complaining of the deterioration of Thai society, increasing economic pressures on the general population, a rising crime rate, corruption, a loss of traditional values and political chaos.They implied strongly that the military is the only institution that can save Thailand.

This morning's papers -- published before Prem's return to power -- said the revolutionary council had restored parliament and intended to have an elected prime minister and a new government set up within 15 days. They also carried a program to improve the economy.

All that is moot now, but Prem will have the task of pulling together his government to tackle many of the problems that the revolutionary council was aiming at.

Some obsrevers here said the dissatisfaction with Prem's policies will force him to greater action.

This sixth attempted coup in Thailand in the last decade differed from its predecessors. It appeared to be a poorly planned affair. In past coups, the military remained united instead of being badly split as it was here this week.

Sant apparently took action before his movement was well organized, although he claimed total military support. In fact, he had the key First Army, Thailand's largest, which is based in Bangkok and includes units stationed on the Cambodian border. Nonetheless, Prem was able to retain the support of the other three regional commands as well as the Air Force, which to show its feelings flew jets over the capital Thursday and later showered the city with anti-Sant leaflets.

Prem was also aided by the royal family's statements in his behalf, the first direct involvemnt of the monarchy in politics since the 1973 coup.