King Juan Carlos of Spain abdicates
King Juan Carlos of Spain has announced his intention to abdicate, after nearly 40 years on the throne.
"A new generation must be at the forefront... younger people with new energies," the 76-year-old king said in a televised address.
His son, Crown Prince Felipe, 45, will take over the throne.
For much of his reign, Juan Carlos was seen as one of the world's most popular monarchs, but recently many Spaniards have lost confidence in him.
His reputation has been tarnished by a long-running corruption investigation into the business dealings of his daughter and her husband.
Support for the king fell further when it was discovered he had been on a lavish elephant hunting trip to Botswana in April 2012, in the middle of Spain's financial crisis.
The first announcement about the abdication came from Prime Minister Mariano Rajoy, who told reporters: "His Majesty King Juan Carlos has just informed me of his desire to renounce the throne and begin the process of succession."
Later, the king himself said in a televised address that it was time for a "new era" in which a new generation could take on the transformations and reforms required.
He said his son, Prince Felipe, had the maturity and preparation to be king.
Left-wing groups have called for protests in support of a referendum on the future of the monarchy, with the El Pais newspaper quoting police as saying some 20,000 people have gathered in Madrid's Puerta del Sol square.
Several thousand people were also reported to have gathered in the Barcelona in the Placa Catalunya square, some carrying large Catalan flags.
Analysis: Tom Burridge, BBC Madrid correspondent
King Juan Carlos' abdication will be a surprise to most people in Spain, but not a shock.
At the beginning of this year, before his youngest daughter appeared in court in a major corruption investigation, the Spanish media was awash with speculation about the king's future.
But royal officials had said abdication was not an option and that the king's popularity was improving after a clear decline in the polls. They insisted that his mobility was also getting better, after several operations to his hips.
The royal household has always been keen for any decision over abdication to not come in the wake of intense media pressure. That is because Republicanism is a relatively potent force in Spain.
Royal officials are describing this as a "personal" decision, which the king has been considering ever since his 76th birthday in January.
Spain does not have a precise law regulating abdication and royal succession, and Mr Rajoy said ministers would hold a special meeting to discuss the process by which the prince would take over as Felipe VI.
The prime minister said Juan Carlos had been a "tireless defender of our interests".
"I'm convinced this is the best moment for change," he added.
Juan Carlos took the throne on the death of General Francisco Franco, the right-wing dictator who ruled for 36 years after his victory over Republican forces in the Spanish Civil War.
The king became Spain's first crowned head of state for 44 years.
But he soon ignored Franco's supporters, who wanted an extension to autocratic rule, and ushered in a new system of parliamentary monarchy.
As the years went on the king involved himself less in day-to-day politics, and became more of a figurehead.
He has been credited as a stabilising force for independence-minded areas such as Catalonia and the Basque region, and he also helped defuse an attempted coup in 1981.
Until a few years ago his popularity was high, but the hunting trip and corruption allegations involving his youngest daughter, Cristina, and her husband Inaki Urdangarin, led to calls for him to step aside.
The king's son and successor, Felipe, appears to have been untarnished by the scandal.
Felipe and his wife - former television presenter Princess Letizia - have recently taken on more important roles in ceremonial events.
Recent European Abdications
June 2014: King Juan Carlos of Spain steps down, saying he is passing the role to a younger, energised generation.
July 2013: Belgian King Albert II abdicates in favour of his son, Philippe, for health reasons.
April 2013: Queen Beatrix of the Netherlands hands the throne to her son Prince Willem-Alexander, saying he is ready to reign and it is time for the throne to be held by "a new generation".
But the BBC's Ignacio del los Reyes, in Spain, says there is still concern over whether the couple will be able to save a damaged institution.
On social networks, people are already asking whether it is time for Spain to become a republic, and some parties are calling for constitutional reform and a popular vote to pave the way for this change.
But the two main parties in parliament remain loyal to the monarchy, our correspondent says.