The heaviest fighting yet between Peruvian antiterrorist units and Maoist guerrillas left a reported 20 guerrillas and six police officers dead yesterday outside the Andean city of Ayacucho, 270 miles southeast of here, authorities said today.

The battle came four days after a guerrilla bombing spree in Lima led the government to impose a state of emergency in the capital city and neighboring province of Callao.

Thirteen policemen were reported missing near Ayacucho after members of the guerrilla band Sendero Luminoso (Shining Path) attempted unsuccessfully to take the town of Vilcashuaman. According to police reports, more than 200 guerrillas, armed with dynamite and automatic weapons, were involved in the predawn raid.

Sendero Luminoso is also believed to be responsible for 12 explosions that rocked Lima last Thursday night under the cover of a citywide blackout. The blasts caused two deaths and $4 million in damages to government buildings and private businesses.

According to government officials, it was the most serious guerrilla assault on Lima since Peru's return to democratic government two years ago.

Prime Minister Manuel Ulloa announced the suspension of constitutional guarantees in Lima and Callao during a televised press conference on Friday. The action affects more than 5 million inhabitants of the Lima metropolitan area, nearly one-third of Peru's population.

The emergency measures are the most dramatic steps taken by the government so far to face the growing guerrilla challenge.

During July, a string of political assassinations and bombings stretching from the Andean highlands to downtown Lima--with 300 incidents registered by the government in all -- placed President Fernando Belaunde Terry under increased pressure from the public and military to pin down Sendero Luminoso. Belaunde declared a state of emergency in five central Andean provinces, sending antiterrorist police reinforcements to the guerrilla stronghold of Ayacucho, a windblown section of the Andes that is one of the poorest regions in Latin America.

Little has been learned about Sendero Luminoso since the group surfaced in 1980, the first year of Belaunde's presidency. Diplomatic sources here called the group "one of a kind in Latin America." Political analysts described Sendero Luminoso as a band of Maoist extremists drawing on a tradition of Andean messianic movements, saying it is more closely related to the history of Inca warriors than to international communism.

Although Belaunde has maintained that Sendero Luminoso is relying on covert foreign assistance, all of the arms recovered from the guerrillas so far have been identified as Peruvian, presumably stolen in raids on police outposts during the last two years.

The accumulated firepower has enabled the guerrillas to stage impressive hit-and-run operations, pulling off well-coordinated attacks on isolated police posts, haciendas and power stations.

During July, guerrillas killed at least five provincial government officials and suspected police informers following "people's trials." On Aug. 3, 140 well-armed guerrillas on horseback sacked the University of Huamanga in Ayacucho, causing approximately $2 million in damage before fleeing to the countryside.