Revolutionary militiamen arrested former prime minister Shahpour Bakhtiar, his war minister and several leading generals today while the new prime minister, Mehdi Bazargan, formed the nucleus of a government and attempted to restore order to Iran.

The seven members of the new Cabinet included two top leaders of the National Front, to which Bakhtiar had belonged before accepting the shah's call to become prime minister. They are Karim Sanjabi, named foreign minister, and Dariush Forouhar, named minister of labor and social affairs.

Bazargan named no defense or finance ministers, indicating the government would be broadened later. Both posts are crucial, with the army in disarray and the nation's finances strained by turmoil and oil field strikes.

Backed by a nationally televised appeal by Ayatollah Ruhollah Khomeini, the 78-year-old symbol of the revolution, the new government sought desperately, but apparently ineffectually, to recover tens of thousands of weapons taken from captured armories and military garrisons during the climactic 24 hours of the overthrow of exiled Shah Mohammad Reza Pahlavi's caretaker government.

Khomeini threatened to "cut off the hands of traitors" and deal ruthlessly with the armed revolutionaries who are refusing to turn in their weapons. He said anyone who keeps his weapons is not a "true Moslem."

"The state must be preserved," he added. "The disorder must end."

While there was scant evidence that the street fighters were heeding his call, Tehran and most of the provinces nevertheless returned to a semblance of order after three days of anarchy.

The principal exceptions were a brief shooting spree between rival leftist guerrilla groups in Tehran University, exchange of gunfire at the east Tehran airport training base where the year-long uprising peaked Saturday, an aborted attack by a splinter guerrilla group on the prime minister's offices and scattered vigilantism in an atmosphere of score-settling.

Apparently looking ahead to the possibility of a civil war between opposition factions, the new government began a concerted effort to reconstitute Iran's shattered armed forces.

It broadcast numerous appeals on state radio to deserters to return to their bases and for army officers in the provinces to report to Tehran -- in civilian clothes for safe passage -- to form a new officer corps.

But the first critical test of the new government will be to undo that which was essential for the revolution to succeed -- the distribution to civilians from a broad spectrum of political ideologies the weapons needed to make Iran's military back down.

The network of Tehran's mosques, the infrastructure around which the religious and secular opposition rallied to foment the revolution against the shah, was being used today in an attempt to gather the arms.

But random visits to mosques by reporters showed little evidence the appeals were meeting with success, and there was no sign of arms being surrendered at Khomeini's headquarters in south Tehran.

In Qom, Ayatollah Kazem Shariatmadari issued a statement on the Voice of the Revolution, formerly Radio Iran, saying public disorder was "punishable in hell." He directed revolutionary militias that arrest officials of the former goverment not to try them summarily, but to hand them over to authorities.

The general staff of the provisional government also issued a statement saying, "Now that the national army is under the control of the revolution, we appeal to the dear general public to consider military personnel as their brothers..."

But the new government and its obviously disorganized militias were not restrained from making their own arrests in what appeared to be a wave of retribution.

Officials of Khomeini's headquarters confirmed that Bakhtiar, for 40 years one of Iran's leading opposition figures and a victim himself of political imprisonment by the shah, had been captured after going into hiding Sunday. He was arrested by guerrillas and Air Force cadets with his war minister, Jaffari Shafaquat, and taken to the prime minister's office. From there, he was transferred to Khomeini's makeshift revolutionary headquarters and held on unspecified charges, they said.

A spokesman for Khomeini, when asked whether Bakhtiar will be tried for crimes, said, "I'm sure he will. If he is arrested, there must be a trial."

Other opposition sources were less certain that Bakhtiar, who reportedly had been promised safety by Bazargan, would be tried. If he is tried they said, it is doubtful he would be imprisoned.

Observers noted that the new government has been under intense pressure from its followers to arrest Bakhtiar, and that his detention may have been designed to satisfy that pressure.

Also arrested today were 10 generals, including Army aviation commander Manuchehr Khosrowdad, who had previously been reported to have fled the country in a helicopter.

Revolutionary militiamen also rounded up top officials of SAVAK, the hated secret police, and many SAVAK agents.

Sanjabi, the new foreign minister, sought last year to involve his group in a proposed coalition government while the shah was still monarch. But he backed away when Khomeini declared from exile in France that anyone who participated in the coalition would be expelled from the Islamic-inspired revolutionary movement.

Forouhar represents the Iran National Party wing of the National Front. The remaining five ministers are mostly unknown technocrats with clean political records.

They are: Ali Akbar Moinfar, an engineer who was appointed minister of state; Mostafa Katiraii, an engineer named housing and urban affairs minister; Yousef Taheri Ghazvini, an engineer named minister of roads and transportation; Ahmad Sadr Haj-Seyed Javadi, a judge named interior minister; and Karem Sami, a physician named health minister.

A Khomeini aide said the new chief of staff, Gen. Mohammed Wali Qarani, will direct the Defense Ministry until that portfolio is filled.

Sanjabi, in an interview published in the Kayhan newspaper, said today that the new Islamic republic will be a democreacy in the ordinary sense but with an "Islamic identity."

"The economy will be mixed and we shall have public investments. Basic industries, which by their very nature are exclusive, should be run by the public sector. Of course, in other sectors, private investment and enterprise should be protected," Sanjabi said.

Throughout the day, militiamen continued to arrest foreigners and parade them blindfolded into the Khomeini headquarters compound, often to be released immediately.

In midafternoon, a busload of about 40 captured British citizens who work in a British government-owned arms sales firm were brought in and detained.

Their managing director, Peter Tozer, accidentally became separated from the guards and while he wandered around the Khomeini press center he told reporters his staff had been burning some documents when a group of armed guerrillas arrested them. They were released after a British consular official intervened with Khomeini's aides.

Also being herded into the compound were several groups of Afghan laborers. While Khomeini's top aides have ordered the militias not to arrest foreigners indiscriminately, the lack of command has made the order hard to enforce.

"There might have been some torture but I know nothing about it because I was not handling those things," Nassiri said. "More junior officers might have done what you say, but I know nothing about it."

At a news conference, Hoveyda likewise denied any involvement in atrocities by SAVAK, which he said did not report to the prime minister.

"The SAVAK had a head and he must respond," Hoveyda said.

SAVAK is in tatters, like the other pillars of the shah's autrocratic rule. It was about to be abolished formally by the ousted government of Shahkour Bakhtiar when it was swept away over the weekend.