Music mogul-turned-top Hollywood home designer Sandy Gallin quietly — and spontaneously — tied the knot this past week with his much younger partner of five years, Bryan Fox, Page Six has learned.

Sources said Gallin, 73 — the manager who repped Michael Jackson, Barbra Streisand and Mariah Carey — and Fox, 34, were at Gallin’s lawyer’s office to plan their nuptials when Gallin suggested they get married on the spot.

“Sandy’s lawyer, Martin Kaminsky, is also his best friend from childhood,” a friend told us. “So Sandy and Bryan were at Greenberg Traurig to plan their wedding and sign papers. Sandy said, ‘Why don’t we do it now?’ When Kaminsky ­replied, ‘But you’ll need witnesses,’ Gallin joked, ‘Well, you have about 500 secretaries — let’s bring them in here.’ ”

Kaminsky then asked the couple if they wanted the “long, medium or short” version of the wedding. The happy pair opted for the short, and they were married.

“They’re planning on having a party to celebrate in the Hamptons when the weather turns nice,” the source added. “After the wedding, they hopped on Ron Meyer’s private jet and headed back to LA right before the storm hit New York.”

Sources said Fox has been a great support to Gallin while he battled multiple myeloma, and made a recovery. “Bryan was unbelievable,” said a friend. “He was there every second and proved to be really smart, handling all the doctors.” Fox, an actor who drew media attention by hanging out with his twin brother, Aaron Fox, on Barry Diller’s yacht along with Gallin in 2009, will appear in a short film he produced and directed.

Gallin, who’s featured in the March issue of ­Architectural Digest, has recently designed homes for moguls Jeffrey Katzenberg, Jimmy Iovine and Irving Azoff. He’d previously renovated and sold 49 of his own houses over the years to buyers from Frank Sinatra to Mark Burnett. But in 2012, Katzenberg asked Gallin to “executive produce” his house for him, which the former manager is now doing for other A-listers.