The 75-year-old king, who has appeared in public this year on crutches, waved at journalists from the front passenger seat as he was driven away in an official car from the private Quiron hospital in the western suburbs of Madrid.
"His majesty the king received his discharge after completing the post-operative period very satisfactorily and having achieved sufficient autonomy for daily life," hospital manager Lucia Alonso told reporters, reading out the latest medical bulletin.
Visiting doctors from a US clinic on Thursday 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 area around the previous joint became infected.
"The latest results from biopsies and microbiological cultures confirm the disappearance of the infectious process in the hip," the hospital said Monday.
"In the next weeks, Don Juan Carlos will continue with his treatment, post-operative checks and a planned outpatient recovery programme."
Surgeons said after the operation that they expected the king to walk again unaided in 10-12 weeks but warned he would have to avoid running and vigorous sports.
Thursday's procedure was the king's 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 in recent months and the news of the latest operations had fuelled speculation of a possible abdication, but the palace has flatly denied the king was considering such a possibility.