It’s both ironic and fitting that Victor Gotbaum, longtime leader of New York City’s largest municipal-workers union, died on the 40th anniversary of the fiscal crisis.

Fitting, because Gotbaum played a key role in helping avert a catastrophic municipal bankruptcy.

Yes, as E.J. McMahon noted on these pages Friday, the idea that the unions sacrificed to save the city has been badly overblown. In fact, Gotbaum got Mayor Abe Beame to back away from his most dire layoff and pension threats.

But Gotbaum did, along with teachers union chief Albert Shanker, opt to invest more than $3 billion from their pension funds in decidedly risky municipal bonds — giving Beame vital breathing room to stave off bankruptcy.

And — as Detroit retirees recently, and bitterly, learned — the risk to union members’ pensions was very real. It’s hard to envision today’s union leaders as willing to take that same risk.

Gotbaum was no saint. A few years earlier, DC 37 workers abandoned city vehicles on the bridges — a tactic The Post at the time likened to terrorism. But he acted responsibly when it mattered most.

Which is one reason why financier Felix Rohatyn, architect of the city’s fiscal survival, recently said Gotbaum “probably did as much as anyone to help save the city.”