A court in Egypt has ordered the release on bail of two Al Jazeera journalists being retried for allegedly aiding the banned Muslim Brotherhood.
Mohamed Fahmy and Baher Mohamed were imprisoned in June along with their Australian colleague, Peter Greste.
But their convictions for spreading false news to help a terrorist group were overturned on appeal last month.
Mr Greste was freed last week under a law allowing the deportation of foreign nationals to their home countries.
Mr Fahmy has given up his Egyptian citizenship to qualify for deportation to Canada, but Mr Mohamed has no foreign passport.
The journalists strenuously deny collaborating with the banned Muslim Brotherhood after the overthrow of President Mohammed Morsi by the military in 2013. They say they were jailed simply for reporting the news.
Mr Fahmy and Mr Mohamed were led into a soundproof glass cage - which allows judges to limit defendants' ability to protest or interrupt proceedings - at the start of their retrial at the Cairo Criminal Court.
Mr Fahmy - his arm in a sling because of an injury he suffered before his arrest in December 2013 - was later allowed out of the dock to address the court.
"A security official visited me and asked I drop my citizenship because the state wanted to get this case done with, it had become a nightmare," he said before unfurling an Egyptian flag.
After a brief recess, Judge Hassan Farid adjourned proceedings until 23 February and ordered that the two men be released, along with 11 other defendants - most of them students - charged with involvement with a terrorist group.
He set bail for Mr Fahmy at 250,000 Egyptian pounds ($33,000; £22,000), while Mr Mohamed was freed without bail.
Timeline: Journalists' detention
- 29 December 2013: Peter Greste and Mohamed Fahmy arrested in police raid on Cairo's Marriott Hotel. Baher Mohamed later arrested at home
- 29 January 2014: 20 people including the three journalists referred to trial, charged with spreading false news, belonging to a terrorist organisation and operating without a permit
- 22 February: First court appearance of the three journalists
- 23 June: Defendants sentenced to seven years, with Baher Mohamed receiving an additional three years
- 12 November: President Sisi signs decree allowing repatriation of foreign prisoners
- 1 January 2015: Highest court orders retrial, but the three journalists not allowed bail
- 1 February 2015: Peter Greste freed and deported, his two colleagues remain behind bars
- 12 February 2015: At the start of their retrial, the judge orders the release on bail of Mohamed Fahmy and Baher Mohamed.
The courtroom erupted in applause following the decision. Mr Fahmy's fiancee, Marwa Omara, broke down in tears and cried: "Long live justice."
Shortly afterwards, Mr Mohamed declared on Twitter: "I AM FREE."
Mr Greste wrote: "CONGRATULATIONS... This is a huge step forward. Not time to declare it over, but at least you get to go home!"
Mr Mohamed's wife, Jihan, said: "I am happy but my happiness is incomplete until he gets acquitted."
The first trial of the journalists, at which they were sentenced to between seven and 10 years in prison, was widely condemned internationally and the Court of Cassation ruled on 1 January that the original court had been "hasty in pronouncing its verdict".
On Monday, the deputy head of the Court of Cassation, Judge Anwar Gabry, said prosecutors had failed to present conclusive evidence that the defendants helped the Brotherhood or promoted the group.
He also said the trial had failed to investigate claims that the defendants had given testimony under duress.
Before the retrial began, families of the journalists said they feared the process might not be fairer the second time around, reports the BBC's Orla Guerin in Cairo.
Mr Fahmy's relatives described the retrial as their worst nightmare.
"We blame the Canadian government and the Canadian embassy for not doing enough," Ms Omara told the BBC's World Update programme.
"They kept telling us: 'Don't worry. Mohamed will be released in a matter of days.' So I quit my job and packed my bags... And I was just waiting for a call from them to go to the airport and meet Mohamed there. But this call didn't happen."
Mr Mohamed's wife said it was unjust for him to be on trial when a colleague convicted in the case was already a free man.
President Abdul Fattah al-Sisi, the former military chief who ousted Mr Morsi, has said he will not consider a pardon before the courts have finished their work.