A foreign national convicted of drug dealing and recommended for deportation is entitled to damages for unlawful detention, the High Court has ruled.

Attempts by the Home Secretary to remove Paul Ricky West to either Jamaica or Ghana after he served a jail sentence were frustrated by "a total lack of documents" and uncertainty about his origins, said a judge.

West, jailed for supplying heroin and crack cocaine, was entitled to damages because the Home Secretary continued to detain him after it should have been realised he could not be deported "within a reasonable period", ruled deputy high court judge Philip Mott QC.

The judge said: "Had the (Home Secretary) acted with reasonable diligence and expedition, and made her own inquiries earlier, she would have realised that deportation could not have been effected within a reasonable period, and also realised that further detention was not reasonable in all the circumstances."

The law said that if it became apparent that deportation could not take place within a reasonable period the secretary of state "should not seek to exercise the power of detention".

The judge assessed West had spent 13 months in unlawful detention and said the amount he should receive in compensation would have to be assessed by the courts if both sides could not agree.

The court heard various "inconsistent" accounts of his life, including that the 36-year-old was born in Ghana to a Ghanaian father and a Jamaican mother.

He said in one account he was taken to Jamaica at the age of three months, where he was raised by his mother and then by an aunt after his mother moved to the UK.

He said he joined his mother in the UK in 1995 at the age of 16 and worked in various jobs until his arrest for drug offences in November 2005.

The judge said the total lack of documents meant there was uncertainty about West's identity. He had no known family or contacts in Jamaica.

West said after his arrest that he had been born in Birmingham, which he later changed to London, before saying, in February 2007, he had been born in a hospital in Jamaica, and then in October 2007 claimed to have been born in Ghana.

He was sentenced to four and a half years for supplying heroin and crack cocaine in Cardiff - reduced on appeal by one year. After completing the custodial part of his jail sentence, he was held in immigration detention from August 27 2007 to January 14 2010, when he was released on bail.

The judge said: "This is a period of over two years and four months, substantially longer than the period of imprisonment he actually served for his offences."

A monthly detention review in November 2008 revealed that moves to deport him were at an impasse because of the uncertainty over where he was from. At that stage it became unreasonable to continue his immigration detention, declared the judge.

Moves should have been made to find a suitable bail address by early December 2008. Instead, West was not released until January 2010, which meant he had spent 13 months in unlawful detention.

West was arrested after police ran an undercover operation in Cardiff and made test purchases of heroin and crack cocaine. On four occasions between November 22 and 24 2005 West was recorded as being a supplier.

On his arrest he was found in possession of £667 in cash and wraps of heroin and crack cocaine, and a number of phones were found in the house.

He told police he had met a man in Birmingham who had taken him to Cardiff. He said he intended to stay no more than a week to get £350 he claimed the man owed him in connection with the sale of a motorbike. The man said he would find him work, and the only work available was selling drugs.

The judge described him, on his account, as a man, then aged 26, "with no previous convictions and no drug habit who had become involved in a major drugs supply business for a few days for purely commercial reasons".