A delegate of the Minister for Immigration found that the 36-year-old Tamil, who has a wife and child in Sri Lanka, had a well-founded fear of persecution in Sri Lanka, but refused his application for a protection visa because he had been assessed by ASIO to be a risk to security.

Led by David Manne, the legal team that successfully challenged the government's Malaysian people-swap agreement launched the High Court action on M47's behalf in May, challenging the validity of the decision to refuse him a protection visa and challenging his continued detention.

''This is a significant victory for our client,'' Mr Manne told the National Times.

''The court has held that the processing of his protection visa, which is crucial to his freedom, was unlawful. The only thing that stood between our client, a refugee visa and his freedom was a regulation which the court has ruled is invalid.

''He should urgently be granted a refugee visa and his freedom. The government should now end, not only the detention of our client, but others in a similar predicament.''