Carlos' public presentation of the petition to his Moroccan counterpart was his first official appearance since having surgery on a spinal disc, ThinkSpain said.
Morroco's foreign inmates, most of whom are Spanish, are accused of an array of violations, with smuggling or consuming marijuana the most common, ThinkSpain said.
About 180 Spanish people are jailed in Morocco, the Ministry of Foreign Affairs said.
Juan Carlos said the release of the prisoners was a clear sign of the great friendship between the two kings and the two countries.
Celebrity Breakups and divorces of 2014 [PHOTOS]