Residents in Abidjan's densely populated suburb of Youpougon surrounded the two members of the Patriotic Group for Peace (GPP), whose fighters are often unemployed youths accused by locals of stealing and terrorising civilians.
Dominique Preychkah, a student, told Reuters: "There was one who had a knife and tried to intimidate people. They threw tyres over them and set them on fire."
A Reuters correspondent said that two corpses were lying in the street with firewood burning around them. Dozens of youths, some of them with machetes, stood around cheering.
Residents said the violence started when neighbourhood youths went to a GPP base in Youpougon and demanded its members leave.
One resident, who asked not to be named, said: "The youths didn't want the GPP here because of their violent acts. There were clashes. The GPP killed two of the youths, one had his throat slit, the other his stomach sliced open.
"Out of revenge, the youths captured two of the militia members and burned them."
Security forces later escorted other GPP members out of their base, as residents danced in the street.
One resident said: "Now we can breathe freely again."
The GPP was officially disbanded in 2005 after it occupied a primary school in another residential district of Abidjan, but it soon reformed.
On Tuesday, a member of the group was shot dead in a clash with security forces.