With Iran's supplies of fuel dwindling, public administration crumbling and violence raging in several cities, the United States and most European countries today advised their citizens whose presence is not essential to leave the country.

The warning came as reports reached Tehran of intensive violence in the holy city of Mashhad, in the northeast, that may have left several hundred persons dead or wounded.

Reports that could not be confirmed here said "a few hundred" people were killed or wounded in Mashhad when troops opened fire on demonstrators after an angry crowd lynched several alleged agents of SAVAK, the Iranian secret police, and rioters set fire to a civil defense headquarters.

[According to the official Iranian radio, Prime Minister Gholam Reza Azhari resigned and his resignation was accepted by the shah, Reuter reported early Monday morning. The radio report said the shah asked Azhari to stay on until another Cabinet is formed.]

U.S. Ambassador William Sullivan called in representatives of the American business community in Tehran this afternoon to urge them to send out their families "in view of the scarcity of heating oil and gasoline and gas in this winter period and in light of the conditions prevailing in the major cities of Iran."

Officially, the suggestion that American dependents leave the country, represents no change in the U.S. policy of support for the shah, but diplomatic sources confirmed that U.S. officials are in contact with the opposition and the American commitment to the shah has clearly been tempered by circumstances.

Canada and all the countries of the European Common Market except France issued similar statements.

[In Ottawa, the Canadian government said it had ordered two military jets to evacuate 300 Canadians from the northern Iranian city of Rasht who were stranded because of no domestic flights to Tehran, Reuter reported.]

The American School in Tehran announced that it would not reopen as scheduled Jan. 6, which officials said made it likely that most of the approximately 15,000 non-military American dependents still here would decide to leave.

But it was not clear how they, some 6,000 Britons and those from the other countries would get out. Commercial flights are already fully booked well in advance, and Tehran airport is expected to be closed in the next day or two by a strike of ground personnel.

The recommendation that families and nonessential workers leave Iran was taken by some observers here as a collective vote of no confidence in the shah's ability to end the bloody riots and strikes that have brought the monarchy to the brink of dissolution.

"We don't expect things to improve any time soon," one high-ranking diplomat said.

Supporters of the shah and spokesmen for his regime, however, insisted that he intends to stay in power, find a political solution to the crisis and restore "law and order" to the country. They said the shah still could reimpose orders by force but had chosen a policy of restraint in an effort to concliate his opponents.

They emphatically deny reports that the shah would leave the country, even temporarily, when a new civilian Cabinet under prime minister-designate Shjahour Bakhtiar is sworn in.

The reports that the shah would leave originated with Bakhtiar, who said the shah was considering going out of Iran for rest and medical treatment.Government officials said today that the shah would not even contemplate leaving Iran until order had been restored.

Iran, ambassador to Washington, Ardeshir Zahedi, who has been here several weeks and is deeply involved in the political maneuvering said the shah would "stay here and take care of the country."

Opponents of the government said that nobody with any credibility or political appeal would accept a post in Bakhtiar's Cabinet, but sources close to the shah said Bakhtiar would soon be ready to present a Cabinet acceptable to all but the most absolutist of the shah's foes.

With the army enforcing martial law throughout Iran and battling rioteris in clashes that reportedly left hundreds of people dead, the question of who will control the army and whose orders the troops will follow is a major element in calculating whether Bakhtiar can govern and, by extension, whether the shah can save his throne.

Authoritative sources said Bakhtiar had asked Gen, Fereydoun Jam, Iran's ambassador to Spain, to become minister of defense. The shah's hope is said to be that the troops would have enough respect for Jam, a former army chief of staff, to accept the Bakhtiar government while the shah himself would continue as commander in chief.

Even if Bakhtiar forms a government tolerable to the army and acceptable to the shah, it appears unlikely that such a government would win any favor among the shah's religious and political opponents.

Bakhtiar's former allies in the opposition National Front have expelled him from their group for accepting the shah's invitation to form a government, and demonstrators on the streets of Tehran today were already shouting their rejection of him.

"It doesn't matter who the prime minister is or whether the shah is in the country or outside," a National Front spokesman said. "It's still the same old system."

Over New Year's Eve cocktails at his mansion on a hill overlooking the capital, Zahedi sought to reassure American reporters that the shah and Bakhtiar had worked out a program that the army would accept and that would give the moderate majority of Iranians a chance to turn their backs on those he considers extremists, like Ayatollah Ruhollah Khomeini.

It was hard tonight to resist comparisons with the scene here last New Year's Eve. Then the shah, at the peak of his power and ambition, was host at a lavish party for President Carter, Secretary of State Cyrus Vance and their wives.

An opposition spokesman said today, "Maybe this year the shah can drink with Carter in Washington."

In the space of a year, the shah's power and ambition have crumbled with bewildering speed. The most devastating symptom of the collapse has been the shutdown of Iran's oil industry.

The strike in the oil fields has closed down the exports that support the country and has caused shortages of gasoline, kerosene and heating oil throughout the country.Iran's normal domestic consumption is about 700,000 barrels a day. Current production is down to 227,000 barrels.

The airport strike threat came from workers of the Civil Aviation Organization who have sent letters to airline offices threatening to withhold services for all American and Israeli aircraft and all other planes except those carrying medical or food supplies, airport sources said.

The letter said the action amounting to a boycott of all commercial flights, would take effect Monday unless Iran's military government bowed to several political demands, including the lifting of martial law and the release of political prisoners.

Diplomats said the Iranian military, which has already taken charge of airport security and posted about 2,000 troops around the facility, could take over the striking employes' jobs to keep the civilian part of the airport open, but only with difficulty.

Continuing demonstrations and army shootings in Tehran were overshadowed by what opposition sources called a "massacre" in Mashhad.

A spokesman for the city's leading Shiite Moslem leader, Ayatollah Seyed Abdullah Shirazi, said by telephone that possibly as many as 700 people were killed when troops fired on a large crowd that had gathered to protest an army attack on the ayatollah's house.

He said troops backed by tanks surrounded the house, where a number of people had gathered to mourn victims of army shootings Saturday.

Suddenly the soldiers opened fire, killing 14 and wounding 56, the spokesman said. The ayatollah himself, a conservative leader who has not been particularly outspoken against the shah, was rushed out a back door to safety, his aide said.

The clashes in Mashhad appeared to be among the most serious yet in Iran's year-long wave of disturbances. Residents said demonstrators had taken control of most police stations in the city during the past two days, and yesterday a mob burned an army commissary after distributing its contents to people in the streets.

The army reportedly withdrew from the streets after religious leaders protested today's shooting to military authorities in Tehran.

In the southwestern oil center of Ahwaz, a measure of calm was restored after a day of "serious civil disorders" in which as many as 200 people may have been killed, diplomatic sources said. They said a number of American homes and company offices were firebombed or damaged, hastening an exodus of about 2,000 foreign oil executives, technicians and their families. CAPTION: Map, no caption, By Dave Cook -- The Washington Post; Picture, Soldier fires into the air to disperse hit-and-run protesters in Tehran.