The 75-year-old monarch was all smiles as he left the Quiron University Hospital on Monday.
"Everything is very good. Fantastic. Thank you," he said to reporters from the car as he left for Zarzuela Palace to continue his recovery.
The head of the Spanish royal family arrived at the hospital four days ago.
His wife Queen Sofia, his son Prince Felipe and his wife Princess Letizia and their two young daughters Infanta Leonor and Infanta Sofia visited the monarch during his stay.
The king's daughters Princess Cristina and Princess Elena were also seen dropping by.
It is the King's second operation on his left hip this autumn. He had a hip prosthesis removed at the end of September after he developed an infection in the tissue surrounding the artificial hip.
The temporary one which was inserted at the time was replaced by a permanent one during the most recent operation.