Leaving office today after 34 years as Manhattan’s DA, Robert Morgenthau had a heck of a farewell present for the city and state — $268 million.

The cash was from a $536 million settlement his office and the Justice Department had worked out with Credit Suisse for handling illegal Iranian, Libyan and Sudanese transactions, and had been the source of some strife between Morgenthau and Mayor Bloomberg, who had accused the DA of controlling hidden accounts.

Morgenthau noted the cash had been held in the Federal Reserve Bank of New York. “They haven’t been accredited yet by the city, but maybe they will be,” he quipped. The feds get the other half of the $536 million.

The city might have gotten a bigger percentage of the $268 million if not for Bloomberg’s feud with Morgenthau.

A temporary state law, which is believed to have been passed at the DA’s urging, calls for the cash from such deals to be split 50-50 between the city and state. Morgenthau said the city previously would get up to 60 percent of the cash before the law was passed, while the Bloomberg administration maintains they’d typically get less than the state.

Jason Post, a spokesman for the mayor, said, “We continue to believe that the city should receive all of the money recovered in deferred prosecution agreements, but the amount we received in this instance is set by the newly passed state law.”