The 74-year-old monarch was released Friday after spending the night following a procedure on Thursday to "reduce a dislocation", the royal palace said.
Earlier this month the king underwent a hip replacement after falling during a controversial trip to Botswana.
He apologised for the trip, after reports emerged stating he had been hunting elephants.
"I'm sorry. I made a mistake. It won't happen again," said Juan Carlos, who is president of the Spanish branch of the World Wildlife Foundation.
Royal sources said the king had injured himself after moving awkwardly shortly after his meeting with the United Arab Emirates minister of foreign affairs in the royal palace.