SAN SALVADOR, El Salvador (AP) _ Three gunmen in sports outfits walked up to the army's top spokesman as he rested after a match at a posh tennis club, shot him in the head and draped a red and yellow leftist banner over the body, witnesses said.

Lt. Col. Ricardo A. Cienfuegos was one of the highest-ranking officials to be assassinated in El Salvador since the war between the U.S.-backed government and the rebels began 51/2 -years ago.

''I heard a report (gunshot) and about six men altogether took all the players off the court,'' said of the witnesses who asked for anonymity for fear of reprisal. ''They took us to a cafeteria at the entrance to the court and told us to throw ourselves onto the floor and then they left.''

Witnesses said Cienfuegos, wearing white tennis clothes and shoes, was resting on a courtside bench when the killers approached. He was shot once in the head at practically point-blank range, they said.

A presidential spokesman confirmed the early afternoon shooting at the posh International Sports Club.

Unlike most senior officers in the Salvadoran military, Cienfuegos frequently traveled around the capital without bodyguards. The slight, reddish-haired officer played tennis at the members-only club each noon.

President Jose Napoleon Duarte, speaking to reporters, said the killing was another example of the war - which has been fought largely in the countryside - moving into urban areas.

Cienfuegos was often denounced by name on broadcasts by the clandestine Radio Venceremos, the voice of the Faribundo Marti National Liberation Front, the umbrella group covering the five guerrilla armies.

Witnesses said the gunmen draped over Cienfuegos' slumped body a red flag emblazoned with yellow letters giving the initials of the Popular Liberation Forces, a guerrilla group that has been fighting to take power in El Salvador since 1979.

The Armed Forces Press Committee, which the American-educated Cienfuegos headed, issued a statement saying, ''He adds himself to the list of the heroes of our armed forces who have offered their lives for peace.

''The only reason he was assassinated was because he always fought to keep people informed about the criminal activities of the terrorist hordes,'' it said.''The only weapon he carried was a pen,'' the statement said.

Cienfuegos, in his 40s, left a wife and two young children.

In other developments in Central American conflicts, a rebel leader said the leftist Nicaraguan government, which his group is trying to overthrow, refused to let him enter Nicaragua, claiming the CIA was plotting his assassination to convince the U.S. Congress to resume funding for the rebels.

The rebel leader, Arturo Cruz, told reporters in San Jose, Costa Rica, that the reasons cited by the Sandinista government for barring him were ''ridiculous.''

Nicaragua's Ministry of the Interior said the CIA wanted Cruz to be arrested in Managua so it could ''unleash an international campaign...to show that the Sandinista dictatorship jails democrats like Mr. Cruz.''

If Cruz were not arrested, the CIA was planning to kill him and blame the Sandinista government, the ministry said.

Cruz said he was going to Nicaragua to give bishops a copy of an ultimatum signed by 21 rebel leaders.The document, which had already been sent to the Sandinista government, calls for political reforms and new elections and sets a March 20 deadline for the government to enter negotiations the rebels want supervised by the Episcopal Bishops Conference of Nicaragua.

Rebels have said if no substantial progress in efforts to negotiate a settlement is reached by April 20, the talks should be ended, ''terminating the possibility of a peaceful solution to the national crisis.''

The Sandinistas came to power in a 1979 coup that overthrew the pro-U.S. Somoza regime.