An Alberta judge has granted bail to convicted war criminal Omar Khadr and the federal government says it will appeal the decision.

Khadr was 15 when he was captured by American soldiers in Afghanistan after a grenade was tossed from behind the wall of a compound, killing U.S. Army Sgt. 1st Class Christopher Speer.

Khadr was injured after the U.S. military stormed the compound and was transferred to Guantanamo Bay when he was 16.

His trial began In October of 2010 and the then 23-year-old was facing five war crime charges.

He pleaded guilty to the charges as part of a deal that would see him spend no more than eight years in prison and would make him eligible for transfer to a Canadian facility after serving 12 months.

Khadr has said he only pleaded guilty to the war crimes he was accused of committing as a youth to get out of Guantanamo and be sent back to Canada.

He was flown to Canada in September 2012 and handed over to authorities. He was then transferred to a maximum-security facility in Edmonton and then moved to Bowden Institution in February of 2014.

Khadr’s lawyers asked for bail at the end of March while they wait for the outcome of his appeal on the war crimes conviction in the United States.

On Friday, Court of Queen's Bench Justice June Ross found that Khadr has a constitutional right to apply for bail pending his appeal and she accepted evidence that he presents a low risk to public safety and has been a model prisoner, even though the federal government has branded him a hardened terrorist.

"This is a circumstance where balancing a strong appeal and the public confidence in the administration of justice favour the same result," Ross said in her decision. "He has a strong basis for an appeal and the risk to public safety is not such that it is in the public's best interest that he remain in pretrial detention in a manner that could render his appeal irrelevant."

While his supporters were overjoyed at the unprecedented decision, a "disappointed" federal government was quick to respond and said it would appeal any interim release. "We have vigorously defended against any attempt to lessen his punishment," Public Safety Minister Steven Blaney said in a statement.

Khadr would have to remain behind bars at least until May 5 while terms of his release are hammered out.

(With files from The Canadian Press and ctvnews.ca)