The killings of a Mexican diplomat and his maid, entangled by a web of bitter family emotions, were partially clarified today when a Mexican Embassy official reported that a son and stepson of the diplomat had confessed.

Mexican diplomat Manuel Portilla Quevedo's body was discovered on Halloween in his apartment, in a pool of blood with a bullet in his head. Portilla had been the third-ranking officer in the embassy.

The Mexican maid, Maria del Carmen Cruz, 26, who had been beaten and shot in the head, lay nearby. According to the Mexican account, the motive in the maid's death appeared to have been her elimination as a witness in the death of Portilla.

Acts of violence against foreigners in Moscow are rare. The slayings were not reported in the Soviet press, but news spread quickly within the foreign community, causing considerable anxiety.

Mexican Embassy officials said today they had been told by Soviet Foreign Ministry officials that Portilla's son Jose, 15, and stepson Jorge, 22, had confessed to the killings and Portilla's Russian-born ex-wife, Valentina Sumin, had been indicted for smuggling and selling luxury goods.

Portilla was described in the diplomatic community as a well-connected envoy who spoke Russian, having studied in Moscow, and "knew a lot" but led a ragged private life.

A dispute that flared between Mexican Embassy officials and Soviet authorities over the handling of the case apparently has died down.

The fate of Portilla's son Jose, who was released to the custody of a lawyer, is still uncertain. As a minor with diplomatic immunity, western legal authorities say, the son's status under Soviet law is unclear.

Portilla's former wife, last seen in public when weeping over the casket at the funeral last month, was picked up by police along with three of her four children, according to Manuel, his oldest son, after his release.

Manuel said plainclothed police detained his mother, his brother Jose and stepbrother Jorge in connection with the case. His 8-year-old sister remained at home, he said.

Manuel said that the officers released him and Jose after three days but not before encouraging him to confess during tense questioning. Other family members had admitted to the crime, he said they told him.

Mexican Embassy officials said that Sumin and Jorge were still being held, despite embassy protests.

Last Monday, the Mexican Embassy issued a two-page statement protesting the actions taken against all the family members, including their arrest without the embassy's knowledge, and the prohibition of an interview with them by an embassy officer.

Sumin and all of the children are still Mexican citizens, an embassy spokesman said. Although Sumin lost her diplomatic immunity after the divorce, the younger children did not, the Mexicans added.

Portilla was a plump, engaging diplomat of 43 who had studied, married and worked his way into Soviet circles sealed to most foreigners. "He knew a lot," said a senior western envoy who knew him well. "Clearly he knew more than most of us about this place."

Portilla spoke fluent Russian, read more than a dozen Soviet newspapers every day and kept close contacts among Soviet officials, his diplomatic colleagues reported. He occasionally tipped off western journalists about Soviet political stories.

For his personal life, Portilla could have stolen a chapter from a Feodor Dostoevski novel.

Married to Sumin as a student at Patrice Lumumba University in Moscow in the mid-1960s, Portilla had a tense family life. Between moves to Mexico and back in 1981, his relationship with his wife began to deteriorate, friends report.

His son Manuel speaks of him in hostile tones. "My father had a lot of affairs," he said. He added that the Moscow divorce had not been recognized in Mexico.

After the divorce, three months ago, Portilla threw a big party for his friends. The family lived in one large apartment in a foreigners' compound here and he lived in the one-bedroom flat where the bodies were found Oct. 31.