Two activists were killed and five wounded in El Salvador's capital on Sunday after an assailant opened fire on members of the leftist FMLN party, officials said, in one of the worst political attacks in decades.

No group has taken responsibility for the shooting, which comes amid fierce campaigning for upcoming legislative and local elections in the small central American nation.

A man armed with a pistol fired on a truck carrying activists in the center of the Salvadorian capital, FMLN lawmaker Nidia D?az said.

She blamed the attack on the "hate" fomented by the country's populist president, Nayib Bukele, who days ago criticised 1992 peace accords between the army and the FMLN that put an end to a 12-year civil war that left tens of thousands dead.

Bukele on Twitter accused the party of politicising the shooting, saying three suspects were now in custody.

Two activists were killed and five wounded in El Salvador's capital on Sunday after an assailant opened fire on members of the leftist FMLN party
Two activists were killed and five wounded in El Salvador's capital on Sunday after an assailant opened fire on members of the leftist FMLN party AFP / MARVIN RECINOS

Sunday's shooter was "apparently" a security agent for officials assigned to the Ministry of Health, he added.

Two of the detainees, including the alleged attacker, have undergone emergency surgery, the president said, suspected of having been shot by two FMLN activists who are also in custody.

Photos from the scene showed the blood-stained truck under police guard.

"We have not seen something so dramatic in the 29 years since the peace accords," FMLN secretary-general Oscar Ortiz said, accusing the president of a "campaign of hatred" against the party.

"The electoral campaign cannot turn into a bloodbath," attorney general Raul Melara said on Twitter.

Some 5.4 million Salvadorians will vote for ten political groups on February 28. President Bukele's New Ideas (NI) party currently leads in the polls.