Havana, Cuba (CNN) -- It might be the most bizarre of the closely guarded secrets from last week's historic agreement between the United States and Cuba: How did the leader of a Cuban spy ring serving life in a California federal prison manage to impregnate his wife 2,245 miles away in Havana?
As part of the most significant diplomatic breakthrough between the United States and Cuba in more than 50 years, a prisoner swap was made. To uphold its part of the bargain, the U.S. released three Cuban spies, including Gerardo Hernandez, the head of the spy ring known as the Wasp Network.
Hernandez had an ear-to-ear smile Wednesday as he arrived at Havana's Jose Marti International Airport. State TV showed Hernandez as he was greeted by President Raul Castro and then embraced and kissed his wife, Adriana Perez.
Cubans watching the nonstop coverage of the prisoner swap were shocked when the cameras zeroed in on Hernandez hugging Perez. She was obviously in the late stages of a pregnancy that had no easy explanation.
Not only had Hernandez been serving a double life sentence, but his wife also worked for Cuba's intelligence services and was banned by U.S. officials from visiting her husband in prison, according to the Cuban government.
The subject became the immediate hot topic in Havana where rumors swirled fast about the baby's paternity and whether the Cuban government could have somehow arranged a clandestine conjugal visit under the nose of U.S. authorities.
The couple appeared at another event on Saturday, where together with the other freed spies, Castro and the communist island's top political and military officials showered them with applause.
As the couple left the celebration, Hernandez hinted at the secret surrounding the pregnancy.
"Everyone's asking, and we have had a lot of fun with the comments and speculations. The reality is it had to be kept quiet," Hernandez told the government-run television channel. "We can't give a lot of details, because we don't want to hurt people who meant well."
He said his wife's pregnancy was a direct result of the high-level talks.
"One of the first things accomplished by this process was this," Hernandez said, gesturing to his Perez's stomach. "I had to do it by 'remote control,' but everything turned out well."
Two sources involved with the diplomatic talks, when questioned by CNN, uncloaked the mystery: During the negotiations, Hernandez's sperm was collected and sent to Cuba, where Perez was artificially inseminated.
The U.S. Justice Department confirmed the story, without going into the details.
"We can confirm the United States facilitated Mrs. Hernandez's request to have a baby with her husband," spokesman Brian Fallon said.
What the U.S. would gain
Why would the U.S. government do this? The artificial insemination was made possible in exchange for better conditions for Alan Gross, a U.S. contractor imprisoned in Cuba. Gross was released last week as part of the prisoner swap.
"In light of Mr. Hernandez's two life sentences," Fallon said, "the request was passed along by Senator [Patrick] Leahy, who was seeking to improve the conditions for Mr. Gross while he was imprisoned in Cuba."
The discretion on both sides makes sense.
For 18 months, officials from both countries refused to admit that they were even holding high-level talks.
Officials communicated via back channels, knowing that any leak about the talks could doom the talks.
Impregnating Perez involved cutting through bureaucratic red tape at multiple U.S. government agencies.
As Perez began to show, officials from both countries fretted over how they would explain her pregnancy and what to do if the baby arrived before the talks succeeded.
Hernandez was convicted in 2001 of conspiracy to commit murder for his role in the Brothers to the Rescue shoot down that left four Cuban-Americans dead after Cuban Air Force MIGs blew up the two civilian planes as they flew toward Havana to distribute anti-government leaflets. He received two life sentences.
Cuban authorities said Hernandez and the other operatives were trying to prevent terrorist attacks from being carried out on their homeland by violent Miami exiles.
That the U.S. government helped a man convicted of plotting the murder of four Cuban-Americans and spying on the exile community in Miami will likely further rankle many of the same Cuban-Americans who were already furious that Washington is restoring diplomatic relations with Havana.
But Tim Reiser, an aide to Leahy who worked to broker the landmark agreement with Cuba, said helping Hernandez conceive a child led to better treatment for Gross by Cuban authorities and was an important concession to help reach a historic deal.
"The expectation was that this man would die in prison. This was her only chance of having a child," Rieser told CNN.
Gerardo Hernandez said he and his wife are expecting their baby daughter to arrive in two weeks and they will name her Gema.