It is not known what happened to the rest of the armed men and their nationalities were not immediately known, but Mauritanian officials say the men behind the attack on the French tourists last year are linked to an al-Qaeda-affiliated cell headquartered in neighbouring Algeria.
Security forces had launched a manhunt last week for Sidi Ould Sidna, who escaped from police at the city's main law courts on Wednesday after requesting he be left alone to pray.
Sidna, 20, was accused of murdering four French tourists as they enjoyed a picnic on 24 December by a roadside in southern Mauritania, one of several attacks in recent months which have fuelled fears that al-Qaeda cells in Algeria and Morocco are moving operations further south.
A medical source told Reuters that Sidna had been killed in the shooting, while police and medical sources said one policeman was also killed.
Sidna's escape was a major embarrassment to the West African country.
The authorities quickly suspended officials connected with the case and took the investigating magistrate, who conducted a hearing with Sidna just before he escaped, off the case.
Impoverished Mauritania has tried to reassure tourists, especially from former colonial ruler France, in the hope of preserving a lucrative niche industry that brings in much-needed hard currency to the largely desert country.
The annual Dakar rally, which was due to pass through Mauritania in January, was cancelled for the first time in its 30-year history after the event's French organisers received threats from "terrorist organisations".