A heart-touching secret spurred Andre Agassi to rush home to Las Vegas and tie the knot with fiancee Steffi Graf before she gave birth to their child.

Steffi had been struggling with a difficult pregnancy and Andre wanted to boost her spirits, say sources.

The 32-year-old tennis great had been flat on her back for the past few weeks at Agassi’s sprawling Vegas compound — suffering from extreme discomfort in the final stages of pregnancy.

“Her mother Heidi was so worried about Steffi that she rushed to her bedside, where she’s been camped daily for awhile,” revealed a source close to the couple. “And Steffi has a full-time nurse checking on her as well.”

But as far as Andre was concerned, that still wasn’t enough.

“All through his last tournament in Stuttgart, Germany, Andre was worried sick about Steffi’s condition,” said the source. “He was supposed to play next at the Swiss Indoor tournament in Basel but abruptly pulled out at the last minute and flew back to Vegas, where he hastily arranged a wedding at home with Steffi before District Judge Michael Cherry.

“Andre told a pal, ‘I knew that I had to put Steffi and the baby before anything else in my life, including tennis.’

“He said that getting married would be the best medicine for Steffi — since love is the only drug she can take!”

Divulged an insider: “Andre hated being away from Steffi.

“He said, with all the uncertainty in the world, there was one constant in his life — Steffi. When he got home he popped the question, and she said ‘Yes.’ “