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.
Clemency plea for Briton, 74, facing flogging in Saudi Arabia
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, adding that "I'm grateful to the Saudi Arabian government."
"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.
Three men receive lashes, jail sentence for harassing Saudi women in public
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 condemns foreign criticism of blogger's lashings
Saudi Arabia is Britain's most important trade partner in the Middle East and was its biggest market for arms exports last year.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ