Robert M. Morgenthau, who waged a war on crime for more than four decades as the chief federal prosecutor for Southern New York State and as Manhattan’s longest-serving district attorney, died July 21 in Manhattan. He was 99.

In an era of notorious Wall Street chicanery and often dangerous streets, Mr. Morgenthau was the bane of mobsters, crooked politicians and corporate greed; a public avenger to killers, rapists and drug dealers; and a confidant of mayors and governors. As district attorney, he presided over a battalion of 500 lawyers, a $75 million budget, and a torrent of cases every year, from stock manipulators and extortionists to murderers, muggers, wife beaters and sexual predators, supervising a total of 3.5 million cases over the years, including highly publicized trials, like those of the subway vigilante Bernard Goetz; the Central Park “preppy” killer, Robert Chambers; and John Lennon’s assassin, Mark David Chapman.

In an interview with The New York Times in 2009, he ruminated on the night in 1944 when his Navy vessel went down with 47 of his shipmates. “I was swimming around without a life jacket,” he recalled. “I made a number of promises to the Almighty at a time when I didn’t have much bargaining power — that I would try to do something useful with my life.”