Updated

Former mayor Rudolph Giuliani is thanking his lucky stars that he filed for divorce before he got a book deal.

A district judge has ruled that Giuliani can keep the money he received as a book advance from Talk Miramax Books rather than splitting it with soon-to-be ex-wife Donna Hanover.

Giuliani filed for divorce from Hanover more than a year ago after 16 years of marriage.  The two-book deal negotiated in January 2000 earned Giuliani a $2.7 million advance.

New York judge Judith Gische said the advance is not a marital asset and since the divorce action had already begun, "the marital pot is closed."

Gische did rule that Giuliani's fame allowed him to become "an exceptional wage earner" and therefore Hanover, who was along for the ride during Giuliani's rise, will get a portion of the royalties from sales of the book.

The Associated Press contributed to this report.