Mozambique and Morocco traded insults today at the Organization of African Unity summit about the volatile issue of Morocco's role in a four-year war with Western Saharan guerrillas.

Mozambican President Samara Machel led the attack by accusing Morocco of engaging in a "genocidal" and "parasitical" expansion of its borders into the Western Sahara.

Moroccan Prime Minister Moati Bouabid, who is here representing Morocco's King Hassan II, responded by denouncing Mozambique for hypocritically maintaining "economic, technical and cultural ties with the racist regime" of South Africa.

The Polisario guerrillas have been fighting Moroccan troops in the Western Sahara since Spain ceded its former colony to Morocco and Mauritania in 1976. Mauritania dropped out of the fighting last August and Moroccan troops took up positions in Mauritania's territory.

The war has represented a major failure for OAU mediation efforts. The Carter administration recently increased arms sales to Morocco in a move that has been interpreted by a large number of African countries as giving financial strapped Morocco the ability to continue the war. The Polisario guerrillas are heavily backed by Algeria and generally use Soviet weapons.

The Western Sahara has been a touchy subject at this OAU summit because the Polisario guerrillas, with the support of 16 African governments, have applied for admission to the organization as the Sabraule Arab Democratic Republic.

Morocco has threatened to withdraw from the OAU -- the first time any member has done so in the organization's 17-year history -- if the Polisario guerrillas' government-in-exile is allowed to join as a soverign state.

In a scathing speech that repeadedly was interrupted by the applause of the 1,000 delegates, Machel said that the OAU must not remain silent in the face of Morocco's "invasion and occupation of the Western Sahara" to conduct "a war of extermination."

When Spain handed over its former colony to Morocco and Mauritania, both countries claimed precolonial ties to the Western Sahara. When Mauritania withdrew from the war, Morocco expanded its claims to include the southern region that Mauritania had abandoned.

"What historic rights are these that expand and shrink according to circumstances?" Machel asked. He charged that Morocco had violated the OAU charter and "disrespectfully" ignored OAU and United Nations resolutions on the Western Sahara to allow for a U.N.-supervised referendum.

The Moroccan delegation, which is seated next to the Mozambican delegation, remained quiet during Machel's speech. Machel is the first president of Mozambique, which won independence from Portugal in 1974 after a long guerrilla war. Under Portuguese rule, Mozambique developed strong economic ties to South Africa that still persist.

In his sarcastic rejoinder, Bouabid referred to the Mozambican leader as "Mr. Decolonizer" and "Mr. Savior of Mozambique."

"I would not be surprised if Machel went to South Africa for medical treatment," Bouabid said. South Africa is anathema to the OAU because of its racial segregation policy.

Later in the day, Zimbabwe's Prime Minister Robert Mugabe, making his maiden speech before the OAU, joined in Machel's criticism of Morocco.

"The government and people of Zimbabwe stand firmly behind the people of Polisario in their gallant struggle," Mugabe said. "We plead with our brothers of Morocco to curb their territorial aggrandizement."