Moroccan troops and Polisario guerrillas were battling yesterday in a major engagement of the four-year war for the Western Sahara, with both sides claiming to have killed more than 1,000 of the enemy's forces.

At stake was Smara, the second largest town in the sparsely inhabited former Spanish colony that is known mainly as a source of phosphate fertilizer.

Smara, with a population under 8,000, is the site of the second-largest Moroccan garrison in the territory.

In Cassablanca, a Moroccan government communique said Royal Army troops had killed 1,085 Algerian-backed Polisario guerrillas in weekend fighting to drive off an assault by 5,000 men in desert vehicles. Morocco said 121 of its men were killed or wounded while some 600 vehicles were knocked out by planes and ground forces.

The United States has provided Morocco with F5 jet fighters.

The Polisario Front, in Algiers, first said it had captured Smara after killing 1,200 Moroccan troops and wounding another 1,200. Later yesterday, it said the battle was continuing.

Smara is about 100 miles east of the Western Sahara's biggest population center, the coastal town of El Ayun, and is at the farthest inland point of a triangular strip of territory by Moroccan troops.

The Polisario guerrillas have been waging an increasingly bitter ware to achieve the territory's independence.

The Western Sahara, with less than 100,000 population, was ceded by Spain to Morocco and Mauritania in 1976 but the Mauritanian government gave up all claims to the territory under an agreement signed in august with the Polisario. As Mauritania withdrew, Morocco annexed the southern part.