The settlement was accepted by the court the day the case was scheduled to go to trial. Supreme Court Justice Judith Gische had granted attorneys for the two an extension to finalize details of the settlement worked out in an all-night negotiating session.
"I hope the very, very best for Donna and her future. We have two children. I want everything to work out the very best for them," Giuliani said outside court.
Hanover lawyer Helene Brezinsky told Gische, "We have been able to settle this matter. The agreement has been signed."
Giuliani attorney Raoul Felder said, "Sometimes a birth takes a long time, but it gets done."
Brezinsky said the settlement called for Giuliani to pay Hanover "more than $6.8 million plus all of her litigation expenses and legal fees."
The marriage began falling apart during Giuliani's first term as mayor.
Giuliani, 58, had filed for divorce in October 2000, accusing Hanover, a television personality and sometime actress, of cruel and inhuman treatment. Hanover, in her own filing last month, blamed the ex-mayor's "open and notorious adultery" for the split.
Giuliani has acknowledged having a romance with Judith Nathan.
Hanover, 52, also accused Giuliani of an affair with a former staffer, Christyne Lategano-Nicholas. She and Giuliani have denied the allegation.
In June, the judge ordered Giuliani to pay Hanover child support of $8,000 a month, which, along with other expenses, would bring his monthly payments to her, at least temporarily, to more than $20,000. Giuliani and Hanover have two children, Andrew, 16, and Caroline, 12.
The judge increased the amounts Giuliani had to pay after he acknowledged that he will earn some $8 million this year in speaking fees alone. Hanover had asked for nearly $1 million a year.
Lawyers for both sides had worked hard for the past several days including an eight-hour session July 3 to cut a deal that would keep the city's former first couple's problems from becoming even more exposed in a public trial.
Giuliani left office Jan. 1; term limits barred him from running for a third term.