Spain's former king Juan Carlos, who is facing investigation at home and abroad for corruption, has announced that he plans to go into exile.

The 82-year-old revealed he would leave the country in a letter to his son, King Felipe VI, who accepted his decision, the royal palace said in a statement.

Juan Carlos wrote: "Guided by the conviction to best serve the people of Spain, its institutions, and you as king, I inform you of my decision at this time to go into exile outside Spain.

"It's a decision I take with deep anguish, but great peace of mind."

Investigations are under way in Switzerland and Spain where media regularly publish details of the murky management of funds allegedly paid to the former head of state by Saudi Arabia.

Spain's Supreme Court announced in June an investigation to determine the legal responsibility of the ex-monarch - but only for acts committed after his abdication, due to the immunity he previously held.

The suspicions focus on €85 million alleged to have been paid secretly into a Swiss bank account in 2008.

Juan Carlos ascended the throne in 1975 on the death of the fascist dictator Francisco Franco and ruled for 38 years before abdicating in favour of his son in June 2014.

He was a popular figure for decades, playing a key role in the democratic transition from the Franco dictatorship which ruled Spain from 1939-1975.

Spain's King Felipe VI (L) and his father, former King Juan Carlos, pictured in 2018

But an inquiry opened in Spain in September 2018 following the publication of records attributed to German businesswoman Corinna Larsen, allegedly a one-time mistress of Juan Carlos.

She claimed he had received a commission when a consortium of Spanish companies were awarded a high-speed railway contract to link the Muslim holy cities of Mecca and Medina in Saudi Arabia.

Ms Larsen told Swiss investigators he had transferred her nearly €65 million in the Bahamas, "not to get rid of the money" but "out of gratitude and out of love", according to El Pais daily.

Swiss media reported last March that Juan Carlos was paid $100 million into a Panamanian foundation's Swiss bank account by then Saudi king Abdullah in 2008.

The same month the Daily Telegraph in Britain reported that Felipe VI was also a beneficiary of the foundation.

The king withdrew from his father an annual royal allowance of nearly €200,000 and renounced his inheritance "to preserve the exemplariness of the crown".