A British man imprisoned in Saudi Arabia for breaking anti-alcohol laws has returned to Britain, the foreign ministry said on Wednesday, after a diplomatic storm that threatened to dent UK-Saudi relations.

The family of Karl Andree, 74, said he had been told he faced 350 lashes after a year behind bars for being caught with home-made wine and appealed to the British government in a tabloid-led campaign.

Foreign Secretary Philip Hammond brought up the case during a visit to Riyadh last month and the Saudi authorities said he would be released.

“Karl Andree was released from prison hours after my visit to Riyadh on 28th October,” Hammond said in a statement on Wednesday.

“I’m grateful to the Saudi Arabian government,” he said.

“It’s through the strength and breadth of the relationship between our nations that we have been able to overcome a difficult issue like this.”

Saudi Arabia’s legal code is based on Islamic sharia law.

Andree, a grandfather of seven who has survived cancer, had been living in Saudi Arabia for 25 years, working in the oil industry.

The British government last month abandoned a bid to provide training to the Saudi penal system following pressure from human rights groups over a series of cases including Andree’s.

Saudi Arabia’s ambassador to Britain, in a highly unusual intervention last month, reacted in an article in the Daily Telegraph newspaper saying his country would “not be lectured to by anyone” over human rights.

“To further our shared strategic interests in the years ahead as we confront a variety of threats, it is crucial that Saudi Arabia be treated with the respect it has unwaveringly afforded the United Kingdom,” Mohammed Bin Nawaf Bin Abdulaziz said.

Saudi Arabia is Britain’s most important trade partner in the Middle East and was its biggest market for arms exports last year.