Federal prosecutors in Manhattan accused former Mayor Rudy Giuliani of going over their heads to “other officials in the US government” in an effort to get charges tossed against a wealthy and connected Iranian-Turkish gold trader with ties to Turkey’s president.

The feds said Giuliani — together with former federal judge Michael Mukasey — were hired “to negotiate a disposition” of the case against Reza Zarrab, who was charged last year with violating US sanctions by using US banks to make financial transactions on behalf of the Iranian government.

In their efforts to get Zarrab’s case tossed, Giuliani and Mukasey planned to go to “other officials in the US government” — rather than to prosecutors directly, the government’s letter said.

Mukasey declined to comment, and Giuliani didn’t immediately return a request for comment.

Mukasey’s son Mark Mukasey has been rumored to be a potential replacement for former Manhattan US Attorney Preet Bharara.