In a settlement signed Monday and approved by U.S. District Judge Nina Gershon, both sides agreed to drop dueling lawsuits over the Sensation exhibit and pay their own legal fees.
The judge specifically barred Mayor Rudolph Giuliani and the city from inflicting "any punishment, retaliation, discrimination or sanction of any kind" against the museum.
The deal also commits the city to spend $5.8 million over two years for a museum renovation project.
The settlement came six months after Giuliani calling the painting "sick" froze an annual $7.2 million operating subsidy for the museum, then sued in state court to evict it from its city-owned site.
The judge declared the sanctions unconstitutional late last year in a preliminary order restoring funding. The mayor refused to back down and appealed her decision.
"Tuesday, Mayor Giuliani has agreed that the preliminary injunction that he ridiculed a few months ago will become permanent," museum attorney Floyd Abrams said at a news conference.
Giuliani, who had been scheduled to be deposed in the case next week, was meeting with Republican leaders in Albany and raising funds in Cleveland for his U.S. Senate bid and had no immediate response.
Corporation Counsel Michael Hess insisted the administration was "very gratified" with the settlement. "We felt at this time that it was time to end the hostilities on both sides," he said.
Museum officials, meanwhile, portrayed the agreement as a resounding victory for the museum and for free speech. Abrams characterized the City Hall offensive as "one of the most dangerous assaults on the First Amendment" that he had seen as a veteran constitutional lawyer.