Image copyright Reuters Image caption A combination photo shows Peter Humphrey and his wife leaving court in a police car in August last year

British company investigator Peter Humphrey, jailed in China last August for two-and-a-half years for trafficking personal data, has been released early from prison.

Family friends told the BBC that a Shanghai court had reduced Mr Humphrey's sentence.

His case was connected to the GlaxoSmithKline corruption scandal.

He was released on health grounds and has been moved to a Shanghai hospital for tests relating to cancer.

He will be deported on release from hospital.

Friends of the family said the British consulate in Shanghai is processing an emergency passport. His departure may be as soon as Wednesday.

Mr Humphrey's son, Harvey, said in a statement:

"I am stunned and delighted. I hope to see both my parents as soon as possible. My father may need treatment for his health, but he will soon be able to speak for himself."

Mr Humphrey's American wife and fellow investigator, Yu Yingzeng, remains in prison.

She too was detained in 2013 and sentenced in August last year to two years in prison. She is due to be released on 11 July.

The couple were detained after helping GSK investigate a secretly filmed sex tape of its then top manager in China.

GSK was fined £300m by the Chinese authorities for bribes to hospitals and officials in an attempt to boost sales.

The couple were found guilty of illegally obtaining Chinese citizens' data and selling it to firms including GSK China.

They both admitted buying background information, but said they did not realise this was illegal.

How the case unfolded: