Three policemen were killed and three critically wounded today, in two attacks apparently made by extreme leftist guerillas and designed to thwart plans to hold Spain's first free parliamentary elections in 40 years.

The killings raised to 10 the number of persons slain in Madrid by leftist and rightist gunmen since Sunday and forced Premier Adolfo Suarez to convene another emergency Cabinet meeting to discuss the outbreak of violence that has threatened the survival of his government and its liberalization program.

After its two-hour meeting the cabinet issued a royal decree suspending the constitutional restrictions on unlimited police searches and authorized the police to hold suspects for more than 72 hours. This action confirmed last Wednesday's cabinet decision to give police wide search and arrest powers under the antiterrorism law of the late dictator Francisco Franco.

In announcing today's cabinet action, Information Minister Andres Reguera said that since the terrorism was the work of "tiny minorities," the government had decided against declaring martial law or suspending all constitutional rights.

In today's violence, two policemen were machine-gunned to death by two young men in a postal savings bank in Campamento, a working class suburb of the capital. A few hours later a group of gunmen carried out a similar attack on two police guards at another postal savings bank in the suburb of Cerro de Los Angeles. A police car hurrying to the scene was ambushed by machine gun fire and hand grenades. One guard at the bank was killed and his colleague injured. The two officers in the car suffered serious wounds.

Police, suspecting that extreme leftists were behing today's murders, picked up an undisclosed number of Maoists, Trorskyites and regional separatists for questioning. The arrests followed an Interior Ministry announcement that police would round up all suspected extremists. The statement was later withdrawn without explanation.

The gunmen who carried out today's killings were apparently retaliating for the murder of seven leftists - including five Communists in a leftist labor office - by rightist gunmen since Sunday. Extreme leftists have criticized the Communist Party for its tame and moderate reaction to the incident.

Both rightist and leftist extremists appear bent on the same purpose - to halt Spain's movement to democracy, which is supported not only by moderates but by the Communist Party. Splinter leftist groups consider the liberalization plan too capitalistic and bourgeois and have repeatedly condemned it. They would welcome a military coup which would unite the left and lead to a revolution.

Rightist gunmen, who are losing the police protection they enjoyed under Franco, appear to want to provoke a military takeover by forcing the left to attack police, the military and government officials. Their apparent aim is to bring to power to military officers who would restore Franco's authoritarian regime and exclude the Communist Party, which is now tolerated by Premier Suarez, from Spain's political life.

Following today's killings, Santiago Carrillo, general secretary of the Communist Party, went underground. The mainstream Socialist Workers Party closed down its office and its leaders were not available. A meeting of the leaders of opposition parties called to discuss the outbreak of violence and possible government countermeasures was held under tight security.

Police, in effect, advised all opposition political leaders to avoid being seen in public. Many of them have received death threats in recent days. Premier Suarez recently received a photograph of himself taken through a rifle sight with three bullet holes drawn on his head. The extreme right considers him a traitor to Franco because of his decision to bring democracy to Spain.

His aides, however, do not expect a military coup unless violence reaches greater proportions and warfare breaks out between rightist and leftist gangs.

After the shootings today police set up roadblocks and checked cars throughout the metropolitan area. Key military officers were alerted and troops in the Madrid region were ordered confined to barracks, military sources said.