Mohyadin Mohamed Farah could be back in the community despite a judge calling him a danger to women.

A refugee, who is considered such a risk to women that a deportation order was once made against him, is likely to be back in the community only two years after being made a special patient.

Mohyadin Mohamed Farah had been put into care in October 2015 after he was found unfit to stand trial on charges of rape and assault of a woman.

At the time, Wellington District Court judge Ian Mill said: "You are a risk to women and they need to be protected from your sexual advances."

Farah arrived as a Somalian refugee in New Zealand in 2001.

READ MORE: Family wants danger to women deported

He had served time in a Kenyan jail for indecent assault and had offended here by 2002, earning community work for indecent assault.

In 2004 he was again charged with indecent assault and jailed for two years.

A High Court judge told Farah in 2006 his stalking, kissing and groping strangers - thinking women owed him sexual favours - needed to stop, remarking: "You are proving to be a menace to the country, which has given you refuge."

He had been eligible for preventive detention but was given four years jail.

In 2011 he was charged after grabbing the breasts of a woman on a Wellington bus and telling her he was going to rape her. He also groped a second woman.

On September 11, 2013, Farah allegedly demanded sex from his victim, and when she struggled to get free he raped her.

Judge Mill had declined to make an order for compulsory treatment as that would likely result in him being released back into the community, eventually.

Instead, Mill ordered to have Farah detained in a secure psychiatric setting as a "special patient" – someone declared mentally unfit to stand trial.

He was to be kept on detention in a secure hospital setting and was eligible to spend up to 10 years as a special patient.

The judge made it clear he wanted Farah detained until he could be deported.

The charges were put on hold while he was treated but now he has been found fit enough to stand trial and the charges were back before the court.

On Tuesday the Crown elected to offer no evidence on the rape and assault charges and Judge Bruce Davidson dismissed them, ending the criminal process.

It is understood that Farah, who has been in hospital, is likely to be released, although it is not known when.

Farah's mother had told the court that she felt he would be better off back in Somalia.

Immigration New Zealand (INZ) assistant general manager Peter Devoy confirmed a deportation order was served on Farah in 2008 but was not executed. Somalia had no government at the time that could issue a passport or travel document.

Under the Immigration Act a refugee cannot be deported unless the refugee convention allows expulsion for being convicted of a particularly serious crime and being a danger to the country of refuge, and in Farah's case the legal standard had not been met, he said.

Devoy also said in Farah's case INZ's Cancellation Assessment Panel assessed there was not sufficient evidence to meet the provisions to cancel refugee status under section 145 (b) (iii) of the Immigration Act, and therefore Farah was not able to be deported.