By Elisabeth O'Leary

MADRID (Reuters) - Spain's King Juan Carlos will have hip surgery for a third time, the royal palace said on Friday, reviving speculation the ailing monarch may be close to abdicating.

The 75-year-old monarch, who walks with a cane and has appeared visibly more frail in recent months, has had five surgeries in the last two years. Both of his hips have been replaced and in March he had an operation on a spinal disc hernia.

"His Majesty will have to be operated on to replace his hip prosthesis which appears to be infected," royal place chief of staff Rafael Spottorno told a news conference. "The operation will take place in Madrid in the coming days."

Spottorno said that abdication was a personal decision for the king, but stressed that he had "at no moment" contemplated it.

The King, who helped guide Spain to democracy at the end of the Francisco Franco dictatorship in 1975, was long one of Europe's most popular monarchs, but a series of scandals have eroded public support for the royal family.

The king's son-in-law Inaki Urdangarin has been charged with tax fraud and embezzling 6 million euros ($8 million) in public funds, through his charitable foundation.

Last year, at the height of Spain's financial crisis when the country teetered on the verge of an international bailout, the king fell and broke his hip during a secret safari in Botswana.

Spaniards were outraged that the king - once loved for his common touch - was on an expensive trip at a time when one out of four of his subjects is unemployed.

The king's health, and speculation he would abdicate were top Twitter topics in Spain on Friday afternoon.

Doctors who have examined the king and are advising him on his operation said the monarch was in good shape despite his hip problems, which appeared to derive from an infection in the tissue around the left prosthesis.

There was a 1 to 2 percent chance of such infections developing, the doctors said.

"His general state is better than that of the average patients of his age that I operate on," Miguel Cabanela, a surgeon and hip specialist from the Mayo Clinic in the United States, told the news conference. "He is a vigorous man who is in good shape for his age."

Cabanela said the hip replacement could be carried out in one or two operations, and the recovery time could stretch from eight weeks to 6 months, depending on how many procedures were needed.

Earlier this year a poll showed that half of Spaniards thought the king should step down in favor of his son, Prince Felipe, 45, who has not been touched by scandal and still enjoys strong public favor.

(Additional writing by Sarah White; Editing by Fiona Ortiz and Toby Chopra)