Morocco's first elections in six years have been clouded by charges of electoral fraud and by the kingdom's economic crisis, which observers say portends painful austerity measures and continued limits on political expression.

Both progovernment and opposition parties have condemned the June 10 nationwide municipal elections, accusing the Interior Ministry of withholding and falsifying the results in favor of selected candidates. The largest party in the governing Cabinet, the Independence Party of Foreign Minister Mohammed Boucetta, said electoral fraud had struck "a grave blow to the credibility of the democratic process." Similar charges were made by leftist opposition parties.

A government source denied the charges. "These parties have failed to answer the concerns of the Moroccan people, and so the people weren't with them," the source said. "So they cover this weakness by accusing the administration of fraud."

The conservative government of Morocco's King Hassan is one of the Reagan administration's closest Arab allies. King Hassan facilitates communications between Washington and the Palestine Liberation Organization, has pressed for a moderate Arab stance toward Israel and has granted the United States emergency military facilities.

King Hassan reestablished constitutional government in 1970, after having ruled by decree for five years. More than a dozen parties now compete in Moroccan politics, although within sharply limited political bounds.

The government hopes to complete parliamentary elections, scheduled for September, before having to implement a stringent economic program, according to well-informed Moroccan sources.

The country's rising foreign debt and pressure from the International Monetary Fund will force the government to begin austerity measures very soon, the sources said.

The IMF is scheduled to open talks with Morocco in September, but it is expected to refuse a new loan agreement unless Morocco offers a serious austerity plan, according to Moroccan and diplomatic analysts.

"Especially with the apparent reduction in Saudi assistance, Morocco absolutely needs the IMF," said one western diplomat. "Morocco's room to maneuver is very limited."

Political analysts fear that the IMF might force Morocco to cut basic food subsidies, which account for roughly 40 percent of the government's budget deficit.

Almost exactly two years ago, Morocco's largest city, Casablanca, erupted in protest when the government suddenly raised food prices under IMF pressure. Moroccan troops and armor were used to suppress strikes and riots, and the ensuing political crackdown raised concerns among human rights organizations.

"If the government must substantially cut the subsidies, as many in the IMF and World Bank have recommended, there is a great risk of a new explosion," said a western diplomat.

A special government commission on austerity is said to be resisting cuts in the subsidies. The commission has tightened government accounting procedures and plans to raise taxes, according to a well informed source. The commission is also thought likely to slash the country's development plan by 30 percent and order a devaluation of the Moroccan dirham, although by much less than the 10 to 15 percent reportedly recommended by the IMF.

Morocco's crisis is "a virtual depression," according to one western economist. Domestic commerce and production have been especially sluggish since March, when the country sharply restricted imports because it had run out of money to pay for them.

The interest payments on Morocco's foreign debt last year cost the kingdom 36 percent of its earnings from abroad. Earlier this month, the Reagan administration cautioned King Hassan's government that the United States might be forced to apply sanctions against Morocco for failing to pay $10 million in interest on military loans.

Western and Moroccan analysts say Morocco's plight is largely a result of the global recession, which has reduced demand and earnings for phosphates--Morocco's chief export. The country's costs, meanwhile, have ballooned with the value of the dollar, which has risen from 3.8 to 6.7 dirhams in the past three years. Morocco must pay many of its debts, including its energy bill, in dollars.

"Morocco hasn't been frivolous--its situation is typical of Third World economies in this recession," one observer said. "The expensive dollar and high interest rates are killing them. Even the prudent countries are taking a beating."

Morocco's crisis has been aggravated by a three-year drought, which forces Morocco to import wheat.

Political analysts say the economic crisis and last week's election brought a relaxation this spring of the political restrictions imposed following the June 1981 disturbances. Authorities permitted the newspaper of the socialist opposition party to begin publishing this spring. The paper had been closed by police for nearly two years.

"Morocco's reputation suffered from the crackdown of the last two years," said a Moroccan political analyst. "The government must preserve a democratic image and has been encouraging the moderate political left to participate in this year's elections by giving the impression of a democratic opening."

Before last week's elections, the Socialists had criticized them as lacking credibility. But party leaders decided to take part anyway, splitting bitterly with dissidents who had urged a boycott.

A Rabat court sentenced 34 dissident Socialists to prison terms for allegedly using violence in a confrontation with party leaders. But eyewitnesses said the dissidents had been peaceful and that some had been beaten by local police. No witnesses were permitted in the trial.

The Moroccan political analyst called the trial "a signal" that the government will continue to permit only diluted opposition. A substantial political liberalization seems unlikely, the analyst said, partly because of the economic crisis.