The clash erupted Tuesday when Central African security forces backed by UN peacekeepers went into the flashpoint PK5 neighbourhood to question the leader of an armed group, known as "Big Man", said Vladimir Monteiro, the spokesman of the UN mission MINUSCA.
"During the operation, Youssouf Malinga -- also known as Big Man -- and his men opened fire on the security forces and killed two passers-by, a man and a woman," Monteiro told reporters.
"The security forces responded, killing Youssouf Malinga and one of his men. Three Central African security forces troops were also injured," he added.
Sporadic gunfire continued until nightfall, with militia members retaliating to the operation by surrounding a local apostolic church and killing the pastor, a police source said.
PK5, once a Muslim rebel bastion, is now home to several armed groups that have taken advantage of the weakness of the state since the end of a sectarian conflict pitting mainly Muslim against Christian militias.
Even though relative peace has returned following the civil war that erupted in 2013, inter-communal tensions remain.
As the church pastor tried to urge worshippers to leave, he was attacked and stabbed to death, a family member told AFP.
The information was confirmed by a local peace activist, who identified him as Jean-Paul Sankagui, a former government adviser.
"Jean-Paul Sankagui, pastor of my church in PK5, was killed and the church was torched," Lazare Ndjadder told AFP.
Monteiro condemned the violence.
"It is unfortunate that the civilian population were the victims of these criminals' indiscriminate fire," he said, adding that Big Man and his militia had imposed a "reign of terror" in PK5.
"MINUSCA calls on the population to keep the peace and to avoid any action that might worsen inter-communal tensions," he added.
One of the world's poorest countries, Central African Republic was plunged into civil war in 2013 following the overthrow of former president Francois Bozize, a Christian, by Muslim rebels from the Seleka militia.
Coalition rebels guard the presidential palace in Bangui .
A militia chief and a church pastor were among five people killed in a clash in Bangui, Central African Republic's capital, the UN peacekeeping force said Wednesday.