The 75-year-old king, who has appeared in public on crutches and looking frail this year, could be walking again unaided in no more than three months, surgeons said.
Visiting doctors from a US clinic fitted a permanent prosthesis in a two-and-a-half hour follow-up operation to replace a temporary one that was implanted on September 24 after the previous joint got infected.
"The infection has been overcome. The preliminary test results are positive and everything seems to indicate that things are going well," the surgeon who led the operation, Miguel Cabanela, told reporters afterwards.
He and his US colleague Robert Trousdale, both from the Mayo Clinic in Minnesota, said the king, who is known as a keen sportsman, would get back on his feet but would have to avoid the more vigorous sports.
"He should be able to stand, walk eventually, hopefully without any ambulatory aids," said Trousdale.
"He should not run, but he should get back to most activities that a 75-year-old man wants to get back to."
Thursday's procedure was King Juan Carlos' ninth operation since May 2010. He has had surgery on a benign lump in his lung, his right knee, an Achilles tendon, a slipped disc, two operations on his right hip and three on his left.
The sight of the king on crutches over recent months and the news of the latest operations had fuelled speculation of a possible abdication, but the palace flatly denied the king was considering that.
The king's health has sparked debate about what to do if he is incapacitated and whether he should hand over power to Felipe.
After the operation in September, Prime Minister Mariano Rajoy said the government had no plans to try to regulate the prince's role in case the king is incapable of ruling.
Felipe took his father's place at a national day parade on October 12th for the first time and also replaced him at the annual Iberoamerican summit in Panama last month.