The Iranian government today closed all airports in the country for the second time in 24 hours in an apparent effort to block the return of Ayatollah Ruhollah Khomeini from France.

The government announcement said all flights in and out of the country are canceled until Sunday. Khomeini, the militant Moslem opposition leader, only hours before had reaffirmed his plans to fly home Friday after 14 years of exile.

If the Tehran airport remains closed as announced, analysts raised the possibility of a new outbreak of demonstrations and possible riots by Khomeini supporters angered at the government's transparent attempt to frustrate what has been planned as a mammoth outpouring of rejoicing on the occasion of the 78-year-old religious leader's homecoming.

The government of Prime Minister Shahpour Bakhtiar had reopened the airport only hours before, after briefly closing it to prevent striking employes from sending an Iran Air Boeing 747 to Paris to bring back the ayatollah. The reopening -- and then the sudden reversal announced on midnight news broadcasts -- left nearly everyone in the country puzzled at Bakhtiar's conduct.

There was no indication whether the switch reflected contention within his government, or between the government and the military on which it depends for support.In any case, it underlined the chaotic conditions left by a year of turmoil here and seemed to emphasize the building confrontation between Khomeini and Bakhtiar.

The announcement on Iran's government-run radio said simply the airports were being closed again because of a failure by striking air traffic controllers and the Iran Air employes to end their three-week-old work stoppage.

But an airline official said the decision was taken late tonight by an extraofdinary session of the National Security Council, a body made up of the Cabinet and key military and intelligence officials. This high-level consideration indicated the government's decision had more to it than difficulties caused by the strike.

Only hours before, an emissary from Bakhtiar had arrived in Paris with a "final offer" involving the trade of the prime minister's resignation against key constitutional concessions from Khomeini.

The offer,against the backdrop of Bakhtiar's repeated vows that he would never resign under pressure, suggested increasing desperation as the hour approached for Khomeini's planned return.

Analysts gave Bakhtair's proposal little chance of acceptance in the light of Khomeini's record of brushing aside previous compromise ideas that would block his dream of changing Iran from a monarchy into an Islamic republic.

Even before the envoy arrived, Khomeini had reaffirmed his plans to fly here Friday morning.

As outlined by insiders, Bakhtiar's offer included a request for Khomeini to stay away for three more weeks and drop his demands for setting up a provisonal government, which would organize a referendum asking Iranians if they wanted a monarchy or Islamic republic.

In return, Bakhtiar was reported ready to jettison his previous rigid insistence that any change in the form of government be decided by a new parliament chosen in elections carried out under the present monarchical constitution.

Instead, Bakhtiar was ready to resign and call for elections for a constituent assembly that probably would opt for a republic, although perhaps not an Islamic republic, they said. An Islamic republic worries many nonreligious Iranians, from lay liberals to Marxists, as well as members of the Armenian, Zoroastrain and Jewish minorities.

Bakhtiar would resign, the insiders said, but hoped to stay on as a caretaker prime minister for the one to four months required to organize the constituent assembly process.

Whether the armed forces had endorsed the Bakhtiar proposal was not immediately known. But senior army commanders have sworn to support Bakhtiar less out of love for the man than because he represents the only hope of continuing the monarchy and bringing back Shah Mohammad Reza Pahlavi or one of his heirs.

Bakhtiar is so dependent on the armed forces -- despite the second day running of progovernment demonstrations here that drew an estimated 3,000 Iranians -- that he has told opposition contacts he cannot accept Khomeini's terms for fear of an army revolt.

Bakhtiar argues that if he did, top generals would stage a coup for fear of losing their positions or even their lives under a Khomeini government intent on punishing them for the deaths of thousands killed over the past year.

For most of the day, attention was diverted by the airport dispute. Fearing fatal defiance of his faltering authority Bakhtiar ordered army tanks and troops to close down the airport before dawn this morning. Military vehicles were stationed on runways, but were withdrawn by late afternoon.

Air Force personnel removed starting mechanisms from the aircraft that was to go for Khomeini after Iran Air employes refused Bakhtiar's compromise offer to approve the Khomeini flight in return for agreement from striking employes of the national carrier to assume half a dozen runs.

"We run the airport and not the mobs and Ayatollah Mahmoud Taleghani," a government minister said in justifying Bakhitiar's move and the army's polite, but firm dispersal of a 5,000-strong crowd the prominent Moslem cleric had led to the airport.

The late afternoon announcement from Paris that Khomeini plans to return on an Air France charter had apparently ended the episode until the later decision to close the airports again.

International flights by foreign airlines had resumed and Bakhtiar had assured journalists there would be "no trouble" when Khomeini arrives.

But a foretaste of the later reversal came from police officers who barred the public from the airport this morning, saying: "Knomeini is not coming -- not at all."