The armed forces announced today that troops killed 19 persons in a "successful action" against leftist guerrillas in a city slum early this morning.

Relatives and witnesses insisted that the people killed in the raid had no political connections and were dragged from their homes by uniformed men wearing masks.

Most of the dead were men, but also among them was a 57-year-old woman and a 14-year-old boy, officials at the Ysidro Menendez morgue reported. They were found in their underwear or without their shirts or shoes, many shot directly in the heart or the back of the head.

Teen-age girls in the neighborhood said they were raped by the government troops during the raid, and other neighbors reported that the troops sometimes fired their guns to get into homes.

The U.S.-backed, civilian-military government has come under pressure for its human-rights record as it battles a growing leftist guerrilla movement here. Human rights groups accuse the government of President Jose Napolean Duarte of continuing repression, including the murders of more than 12,000 persons last year. Last week The Washington Post and the New York Times published reports quoting witnesses who charged government forces with a large-scale massacre last month in the rural Morazan Province.

Although the Carter and Reagan administrations have acknowledged various human-rights abuses committed by the armed forces, U.S. officials argue that by giving the troops more advanced instruction they can be dissuaded from such abuses.

The Reagan administration last week certified the Salvadoran government's good-faith efforts to control its armed forces and improve human rights here thus allowing the administration to immediately begin dispersing $26 million in military aid allotted to El Salvador in fiscal 1982. In his certification, Reagan concluded that "progress is being made" by the Duarte government.

The upgrading of the Salvadoran Army has been a major goal of U.S. military aid to the government, which has said the leftist insurgency is inspired and directed by Cuba and other Soviet proxies.

An official armed forces communique attributed the success of the raid today to its forces' "training and professionalization."

"The planning of this action was well synchronized, and we did not have any losses," said the communique issued after reports of the deaths in the San Antonio Abad slum became known.

Shotguns, submachine guns, rifles and bombs were discovered in the "search and elimination of subversive cells," according to the communique.

"We are sorry to say, however, that five members of a patrol were lightly wounded," the statement added. It did not say how the men were hurt. Residents of the slum gave no hint of an attack on the soldiers.

The poor neighborhoods on the northwest edge of the capital have been known as the focus of extensive organizing efforts by guerrillas. But none of the people questioned today would admit any political connections.

The relatives of the dead remember the hours around midnight in painful detail. They told of uniformed men with handkerchiefs over their faces banging on their doors or even firing shots through their windows before dragging people away.

A 16-year-old girl told reporters her 20-year-old brother was taken away, then she and her sisters, aged 14 and 13, were taken behind their home and raped repeatedly by about 10 soldiers. Several of the men, she said, had on military-issue flak jackets.

In another case an adolescent boy hid when soldiers came for his older brother, and then his mother and father went out to find out what happened. He said he found the bodies of all three this morning.

A 16-year-old boy and his 19-year-old sister were awakened when soldiers dragged their father out of the house without any clothes. The soldiers returned with him in a few minutes, got him some pants and took him away again.

"They asked me what he did for a living?" his daughter said. "I told them he worked for the Agriculture Ministry and they laughed like it was a joke." He never returned and his body, too, was found after dawn.

The military communique does not address the question of civilians dying last night. The official account only estimated the number of dead rebels at about 20.