A-Jazeera said that two of its journalists had been released from an Egyptian jail Friday, after spending more than a year in prison on terror-related charges in a case that was denounced as a sham by rights groups and the international community. 

Baher Mohammed and Mohammed Fahmy were freed on bail hours apart, pending a retrial. The network and the relatives of the two say that both were reunited with their families on Friday.

Mohammed's wife, Jehan Rashed, told The Associated Press that her husband arrived home around 7 a.m. Mohammed also appeared in photos posted on the "Free Baher" Facebook page.

Earlier in the day, Fahmy's brother tweeted that he posted $33,000 bail following a court decision that allowed him to walk free. A third co-worker, Australian Peter Greste, was released two weeks ago and deported to his home-country, Australia.

The men had spent more than 400 days behind bars after being charged with terrorism for providing the Muslim Brotherhood, now declared a terrorist organization, with a platform. 

Thursday's decision indicated the court was moving ahead with a retrial of Fahmy and Mohammed. Still, it was greeted with tears of joy and relief by their relatives who attended the hearing in the Cairo courtroom.

Al-Jazeera called the decision "a small step in the right direction" but said the court should dismiss "this absurd case" and release both journalists unconditionally."

The three journalists, who worked for Al-Jazeera's English-language channel, were arrested in December 2013 and accused of belonging to the Brotherhood, which was branded a terrorist organization after the military ousted President Mohammed Morsi earlier that year.

Since the ouster, Egypt has been cracking down heavily on Morsi's supporters, and the journalists were accused of being mouthpieces for the Brotherhood and falsifying footage to suggest that Egypt faces civil war. They rejected the charges against them, saying they were simply reporting the news.

The journalists were convicted by a lower court on terrorism-related charges and sentenced to at least seven years in prison. The Court of Cassation, the country's highest appeals court, said in ordering a retrial that their conviction was based on "flawed evidence" and that the trial was marred by violations of the defendants' rights, according to details of its ruling made public this week.

President Abdel-Fattah el-Sissi had rejected calls from the United States and other Western governments to pardon or commute the sentences. In July, he acknowledged that the heavy sentences had a "very negative" impact on his country's reputation and that he wished they had never been put on trial.

Cairo has signaled it wants to resolve the case and end the criticism ahead of a major economic conference next month to drum up international investment. Egypt's ties with Qatar have thawed, and Al-Jazeera's Egyptian affiliate was shut down.

But officials have never said outright that the controversy would be worked out, insisting on the independence of the courts -- and keeping Fahmy and Mohammed's fate murky.

Several outcomes are possible in the retrial. It could eventually throw out the case, acquit them, convict them but sentence them to time served, or impose more prison time, with the possibility of a pardon from el-Sissi.

The journalists and their families say they were caught in the bitter feud between Egypt and Qatar, the Gulf nation that owns Al-Jazeera and is the main backer of the Muslim Brotherhood.

Greste was deported under a hastily drawn up law allowing el-Sissi to deport foreigners who are on trial or have been convicted. Fahmy has applied for deportation under the same law, which is confusing and unclear. One defense lawyer, Khaled Abou Bakr, noted that Greste remains listed as a defendant in the case even after his deportation.

In asking to be deported like Greste, Fahmy said security officials had pushed him into giving up his Egyptian citizenship so he could be sent to Canada, where he also has citizenship.

"I didn't ask to give up my Egyptian citizenship. I was asked to do so," Fahmy said in the courtroom, wearing a sling on a shoulder that has been injured since before his arrest and only worsened in detention. He said security officials had asked him to do so because the case had become a "nightmare" for Egypt.

Fahmy said he had been told by Canadian officials that his deportation was imminent, and that he and his fiancee had packed their luggage and booked tickets.

For Mohammed, who has only Egyptian citizenship, deportation is not an option. His fate is fully dependent on the verdict in the retrial or a possible pardon.

Fahmy's fiancee, Marwa Omara, broke down in tears after the defendants were ordered freed, and cried: "Long live justice."

"I am very happy. It is a rebirth for me and Mohamed," she said. She added that they will plan their long delayed wedding now.

Canadian Prime Minister Stephen Harper said Thursday that his government was in touch with officials in Egypt "at all levels, including on my level," and was continuing to press for Fahmy's freedom.

"We do remain optimistic that this case will be resolved," Harper said.

Mohammed and 11 other defendants in the case -- mostly students accused of being Brotherhood members -- were ordered released without bail.

Mohammed's wife, Jehane Rashed, also wept with relief. "I am happy, but my happiness is incomplete until he gets acquitted." Rashed gave birth to a child while Mohammed was in detention.

From Australia, Greste expressed his joy and said one of the hardest things he'd ever had to do was leave his colleagues behind. But he said it was too soon for unreserved celebrations.

"The trial is ongoing, and nobody has yet been acquitted," Greste said in a statement. "I'm looking forward to the day when the court declares all of us innocent of the charges. Then the party will really begin."

The Associated Press contributed to this report.