Spain is providing light weapons to Morocco and Mauritania for combating Algerian-backed desert guerrillas in isolated Western Sahara, the former colony that Spain ceded to the two African countries 15 months ago.

According to official Spanish sources, Spain is also training Moroccan and Mauritanian officers in counter-guerrilla desert tactics and in the use of such weapons as the Spanish 106-mm. recoilles rifle in an artilery camp near Madrid. The rifle, based on a U.S. design, is often mounted on a Land-Rover equipped with special sand filters.

It could not be determined whether the United States, which has security arrangements with both Spain and Morocco, was involved. The United States and Spain earlier this month formally began joint military planning under the terms of the bilateral treaty that went into effect last fall.

Vice President Mondale had a long talk here May 17 with Premier Adolfo Suarez. Their discussions included general African developments, but U.S. officials said the Sahara conflict was not raised in the talks.

Spain's support of Morocco and Mauritania stems from the fear that unless they are helped in their fight against Polisario forces, which operate out of Algerian bases with Soviet weapons, the struggle could affect the stability of the strategic Canary Islands. This Spainish archipelago is just off northwest Africa, more than 1,000 miles from Madrid.

The crack Spanish Foreign Legion has been based on the islands since it evacuated from the Sahara in 1976. The Legion left behind weapons and vehicles now being used by Moroccan troops. Reports that Spanish officers are advising Moroccan forces could not be confirmed.

Under the U.S.-Spanish treaty, the Canary Islands are included in the area of common concern and their defense could conceivably be included in joint planning. U.S. officials said that it was possible that the Sahara fighting and the security of the islands were discussed here when Spanish officials met with U.S. Secretary of State Cyrus Vance.

The treaty gives the United States the right to use airports and naval facilities on the islands. Spain is currently building a major Canaries naval base.

The Soviet Union and Cuba, which are making deep military and political penetrations in Africa, operate fishing facilities in the islands. Their trawlers are based at Canary ports.

Algeria not only supports Polisario in the phosphate-rich Sahara but it openly backs the Canary Islands Liberation Movement, which has stepped up revolutionary activities.

Last March a bomb planted by the movement in a Canaries airport caused traffic to be diverted to Santa Cruz de Tenerife, on another island. Shortly afterward, two jumbo passenger jets collided on the Tenerife run way killing 577 in the worst airplane crash in history.

Little reliable information is available here on the Sahara fighting but Western military analysts report that Moroccan troops, operating in the northern Sahara, are holding their own against Polisario's intermittent attacks.

The guerrillas, however, have man aged to disrupt Western Sahara shipments of phosphates on the world's longest conveyor belt, which runs across the desert from the rich Bucraa mines to an Atlantic port 60 miles away.

The military situation in the southern Sahara, which is defended by Mauritanians bolstered by Moroccans, is described as precarious. Analysts said that Polisario is hurting the badly trained Mauritanians and putting a strain on the Moroccans in what appears to be a "no-end war."

Spain decided to yeild the Saharato Morocco and Mauritania in November 1976, following rejection of Algerian demands for a referendum to determine the territory's future. All three countries claimed the colony which Spain had occupied since the 19th century.

Spanish officials said that recent weapons shipments to Morocco and Mauritania included bazookas, rifles, ammunition, mortars, recoilles rifles and desert vehicles. No value was placed on the shipments but they were approved by the Spanish high general staff.

Some Spanish weapons-including light bombs-were apparently taken to Zaire by Moroccan troops sent there to help stem the Katangan invasion from Angola. Officials here have declined comment.

There is little doubt, however, that Spain has become deeply concerned by developments in northern and southern African and wants to have a greater voice in decisions affecting the continent.

For a number of years Spain has provided small weapons to South Africa and it has been a center of clan-destine shipments of weapons to South Africa and Rhodesia. Spanish newspapers recently reported that Rhodesians here have been trying to recruit Spanish, Portuguese and Cuban mercenaries.

Recently Spanish Foreign Minister Marcelino Oreja held a meeting with Spanish ambassadors in Africa to dicuss the growth of Soviet and Cuban influence on the continent.