The operation had been planned following a checkup the former king received in June. King Felipe VI, his only son, arrived at the hospital shortly after midday, accompanied by his mother, Sofia, the queen emeritus.
Arriving at the clinic late Friday, Juan Carlos told reporters, "You'll see me on the way out." The hospital said the former king was moved to the post-surgery unit after the operation. Juan Carlos retired from public life in May. He abdicated in 2014 in favor of Felipe, ending a near 39-year reign.
Revered by many Spaniards, Juan Carlos was considered a key figure in Spain's transition from dictatorship to democracy following the 1975 death of Gen. Francisco Franco.