SAN SALVADOR, El Salvador (AP) _ The Salvadoran air force has received the first of several heavily armed U.S. gunships that could have a significant impact in the war against leftist rebels, American officials say.

The first of the gunships, a C-47 mounted with three .50-caliber machine guns, went into action late Monday in a battle for control of hill country in the east-central province of San Vicente.

In other developments, police reported that unidentified gunmen on Tuesday killed the conservative mayor of Santa Elena, a small town surrounded by guerrilla camps in eastern El Salvador. Police said the motive for the killing of Domingo Aviles was unknown.

Also, a prison official said Tuesday that a former national guardsman who is serving a 30-year-term for the murders of four U.S. churchwomen was thwarted in a plan to escape with three other inmates.

Francisco Orlando Contreras, convicted in the 1980 murders, planned to break out of Ilobasco prison, 33 miles northeast of San Salvador, by racing across a soccer field, tossing one grenade at guards and blowing up a wall with another grenade, said prison director Jose Antonio Arriaza. The escape was set for last week but was foiled when a prisoner told authorities about the plan, Arriaza said.

He said an investigation was under way to learn how two grenades found in Contreras' cell were brought into prison.

Describing the newly arrived C-47 gunship, a U.S. official who spoke on condition of anonmyity said:''It addresses the problem of immediate reaction to attacks. It is very effective for supporting units in combat, has the capacity to fly at night and can carry a lot of accurate firepower.''

The C-47, a version of the DC-3 propeller plane, is the most sophisticated piece of military hardware that the Salvadoran armed forces have received from the United States.

Its three guns are fired simultaneously by a pilot using a specially designed night-vision viewfinder as the plane slowly wheels around its target. The planes can stay in the air for as long as eight hours and fire 550 rounds a minute from each gun.

Another U.S. official said two other gunships will join the force.

Two six-man crews to man the gunship were trained in the United States late last year. The gunships are part of a $70 million supplemental aid package approved for El Salvador by Congress in June 1984. El Salvador received $196 million in military aid in 1984, and Congress has approved $128 million in military aid and training this year.

The gunship took part in its first battle in San Vicente province late Monday, where troops and rebels battled for control of two hills in an area of traditional rebel strength, 42 miles east of the capital.

The Defense Ministry said 15 soldiers died and 24 were wounded in the fighting, but officials at the San Gertrudis Hospital in San Vicente city, just west of the hills, said they had admitted 43 wounded soldiers and many others with serious wounds had been flown to a military hospital in San Salvador.

These were the heaviest government casualties reported since rebels ambushed troops at El Salto, also in the province, on Dec. 1, killing 45, capturing 43, and wounding dozens more.

An army spokesman said guerrillas had taken heavy casualties, but he said he had no figures.