The 72-year-old monarch had a two-hour operation in a hospital in Barcelona and was recovering well, Dr. Laureano Molins Lopez-Rodo said.
"It's good news, the lesion is benign," Molins said at a post-operation press conference, adding that there were "no malign cells" in tissue removed from the upper part of the king's right lung.
Queen Sofia told journalists gathered at the hospital in the afternoon that doctors had said the king could be given the all clear to go home in four days. "He has very impressive health," she said, smiling.
A statement issued by Avelino Barros Caballero, head of the palace's medical team, said doctors carrying out a routine checkup on April 26 and 27 found what was described as "calcification" at the top of the king's right lung.
After further tests — including magnetic resonance scans — they decided to operate on Saturday to remove the nodule. Surgery was directed by doctor Molins, the statement said.
Molins said the king would not need any post-operation medical treatment on his lungs.
"He has not suffered lung cancer," he said.
Juan Carlos used to be a heavy smoker but has not been seen smoking in public in recent years. The palace declined to say whether he had stopped.
Molins said the king's former addiction to tobacco had been an important factor in deciding to investigate the growth through surgery. The nodule had been growing and "capturing glucose" so it was necessary to examine the growth, Molins said.
The origin of the nodule could have been the result of an infection, the surgeon said
Molins said the king's medical team had on April 28 forbidden the king to smoke.
"Cigars are just as bad as cigarettes," he said.
The king carried out his duties as normal on Friday, including an early afternoon meeting with U.S. Vice President Joe Biden at the Zarzuela Palace.
The king and Biden met for 50 minutes and discussed bilateral and international matters, officials said. At a handshake ceremony with Biden the king looked weary.
At a press conference in Madrid on Saturday, Biden said he had no idea the king would be going under the knife the next day.
The king is much loved and respected in Spain after he defended the country's parliamentary democracy from an attempted right-wing military coup in 1981.
On Feb. 23 of that year some 200 soldiers and paramilitary Civil Guard stormed the debating chamber of parliament, firing automatic weapons into the ceiling and shouting orders. They took hostage about 350 lawmakers, causing the deepest crisis in government since Gen. Francisco Franco died in 1975 after nearly 40 years of dictatorship.
The king stood firm, told the soldiers to stand down and in a nationally televised speech defended democracy.
As head of state, Juan Carlos holds a largely figurehead position and rarely speaks out on political issues.
Queen Sofia arrived at the Barcelona hospital just before noon on Saturday.