HALIFAX -- A federal lawyer says a man who was a child refugee from Somalia when he first arrived in Nova Scotia is trying to get Canadian citizenship through the back door despite a violent crime conviction and his possible deportation.

Melissa Grant, who represents the federal public safety minister, told a Federal Court hearing Tuesday that a decision by the Canada Border Services Agency to refer Abdoul Abdi to a deportation hearing should not be overturned by a judicial review.

"What the applicant is actually trying to do here is to seek a de facto grant of citizenship," Grant told Federal Court Judge Ann Marie McDonald, who later reserved her decision in the case.

Abdi, who was born in Saudi Arabia in 1993, lost his mother in a refugee camp when he was four and came to Canada with his sister and aunts two years later. He was taken into provincial care shortly after arriving in Nova Scotia.

He was moved 31 times between foster homes, but he was never granted citizenship while he was growing up in the province.

Abdi developed behavioural problems that advocates say were not adequately treated. Those issues led to problems with the justice system.

The border agency detained Abdi and referred him to a deportation hearing after he served about five years in prison for multiple offences including aggravated assault.

Abdi's lawyer, Benjamin Perryman, argued that the Canadian and Nova Scotia governments failed his client, which is why Abdi should not face a deportation hearing.

"He would be a citizen, if he had been taken care of properly," Perryman said outside the Halifax courtroom.

Perryman told the judge that the decision to send Abdi to a deportation hearing was unreasonable, unfair and contrary to the Charter of Rights and Freedoms and international law.

He said Abdi's aunt had asked the province to grant him citizenship, but he said she was refused -- and the province continued to drag its heels for eight years.

"This is what systemic racism looks like," he said.

Abdi did not attend the hearing. He is living and working in Toronto, which is in keeping with one of the conditions of his release.

Grant said the suggestion that Abdi's rights under the Charter and international law have been violated are premature and based on hypothetical harm.

"This is an administrative process that does not result in any change of status for the applicant," Grant told the court. "All this decision is doing is referring the applicant to the immigration division."

She said Abdi's case does not engage the Charter of Rights, and she stressed that the law clearly states that permanent residents who commit serious crimes can be deported.

As well, Grant said Abdi could seek a so-called danger opinion from immigration officials, which can be used to prevent refugees from being deported to unsafe countries.

However, Perryman challenged those assertions, saying immigration officials will have no choice but to send Abdi back to Somalia if the deportation hearing goes ahead. As for the danger opinion, he said such an assessment wouldn't take into account the challenges Abdi has faced in Canada.

Lawyers from the Canadian Civil Liberties Association and the non-profit advocacy group Justice for Children and Youth also made submissions to the court as interveners.

Jane Stewart, the lawyer for Justice for Children and Youth, said Abdi's interaction with the child welfare system hurt his chances for success.

"We see persistently negative outcomes for children in care," she said, citing studies that show lower scores for education and health.

"He has been disadvantaged as a result of his interactions with the state."

Abdi's case has prompted supporters to call on the Nova Scotia government to intervene on his behalf. As well, the high-profile case has sparked protests at events with federal leaders, including a town hall earlier this year with Prime Minister Justin Trudeau in Lower Sackville, N.S.