Two British journalists detained by a Libyan militia have been released.

Nicholas Davies-Jones and Gareth Montgomery-Johnson, who were detained by the Misrata's Saadoun Swehli brigade for three weeks, have been released and handed over to the government.

The information was confirmed by Libya's deputy interior minister Umar Khadrawi.

The two journalists were arrested on 21 February in Tripoli. They had been in Libya for at least six months at the time of their arrests, but did not have visas.

Davies-Jones and Montgomery-Johnson were both working for the Iranian state broadcaster Press TV.

The head of the Saadoun Swehli brigade, Faraj Swehl, originally accused them of being Israeli spies.

"The British journalists are in our custody and will be released following procedural interrogation," Khadrawi said.

Ahead of their release, the brigade issued a video of the two journalists in what appeared to be good condition.

It is thought they will now be deported.

The government had criticised the brigade detaining the journalists, saying it was "illegal".

Following the collapse of the Gaddafi government and the death of the former leader, the National Transitional Council (NTC) assumed power as an interim measure, but tensions soon surfaced with the rebels who fought against the regime.

The NTC has tried to establish a dialogue with rebel militias across the country, asking them to hand in their weapons.

Last week, interior minister Fawzi Abdelal warned that while the government is committed to continuing to negotiate with the brigades, it would also consider using force against those who refuse to abide by the government's law.