Spain's former king Juan Carlos will leave the country, the royal palace has announced, weeks after he was linked to an inquiry into alleged corruption.
Juan Carlos, 82, made the announcement in a letter to his son, Felipe, to whom he handed power six years ago.
He said he would be available if prosecutors needed to interview him.
In June, Spain's Supreme Court opened an investigation into the alleged involvement of Juan Carlos in a high-speed rail contract in Saudi Arabia.
It was not immediately clear when the former monarch would leave Spain and where he would reside.
It is a humiliating exit for a king who had seemed set to go down in history as the leader who skilfully guided Spain from dictatorship to democracy after the death of General Franco in 1975, the BBC's Nick Beake says.
Juan Carlos abdicated in 2014 after nearly 40 years as king following a corruption investigation involving his daughter's husband and a controversial elephant hunting trip the monarch took during Spain's financial crisis.
What did the letter say?
In the letter, the former monarch wrote that he was making the decision "in the face of the public repercussions that certain past events in my private life are generating" and in the hope of allowing his son to carry out his functions as king with "tranquillity".
"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 leave Spain.
"A decision I make with deep emotion but with great serenity," the letter said.
The statement from the Zarzuela palace said that King Felipe VI had conveyed "his heartfelt respect and gratitude" to his father for this decision.
In March, King Felipe VI renounced the inheritance of his father. The royal palace also said at the time that Juan Carlos would stop receiving an annual grant of €194,000 ($228,000; £174,520).
What is the corruption investigation about?
Spain's Supreme Court has said it aims to establish Juan Carlos's connection with the Saudi project after his abdication in June 2014. At that point he lost his immunity from prosecution.
Spanish firms won a €6.7bn (£6bn) deal to build a Mecca-Medina rail link.