Popular mayor of New York who brought the city back from the financial brink;

Born: December 12, 1924; Died February 1, 2013.

Ed Koch, who has died aged 88, was the bombastic, straight-talking mayor of New York who would famously take to the streets and ask voters: "How'm I doing?" He was mayor from 1978 to 1989 and was credited with rescuing New York from near financial ruin but was eventually brought down by what was seen as an ineffective response to rising racial tensions in the city.

He was born in the Bronx, the second of three children of Polish immigrants, and worked his way through school at a deli counter and selling shoes before serving as an infantryman in the Second World War, finishing as a sergeant.

After studying law, he entered politics in 1952 and was elected to New York's City Council and then to Congress, serving from 1969-77. He served as mayor for three terms and became known for being quick with a quip for friends and a put-down for enemies. "You punch me, I punch back," he once said. "I do not believe it's good for one's self-respect to be a punching bag."

He dismissed his critics as wackos, waged verbal war with developer Donald Trump ("piggy") and mayoral successor Rudolph Giuliani ("nasty man"), and once reduced the head of the City Council to tears. "I'm not the type to get ulcers," he wrote in Mayor, his autobiography. "I give them."

When President George W Bush ran for re-election in 2004, Mr Koch, a Democrat, crossed party lines to support him and spoke at the Republican convention. He also endorsed Mayor Michael Bloomberg's re-election efforts at a time when Mr Bloomberg was a Republican.

He was an outspoken supporter of Israel, willing to criticise anyone, including Barack Obama, over decisions he thought could indicate any wavering of support for the nation.

Among his favourite moments as mayor was the day in 1980 when he walked down to the Brooklyn Bridge during a strike by transport workers and began yelling encouragement to commuters walking to work.

"I began to yell, 'Walk over the bridge! Walk over the bridge! We're not going to let these b******* bring us to our knees!' And people began to applaud," he recalled at a 2012 forum.

He was a champion of gay rights, taking on the Roman Catholic Church and scores of political leaders although he offered a typically blunt response to questions about his own sexuality: "My answer to questions on this subject is simply, 'f*** off.' There have to be some private matters left."

Although a Democrat and a liberal – he called himself a liberal with sanity – in office he pulled to the right on many issues. His answer to the war on drugs? Send convicted drug dealers to concentration camps in the desert. Decaying buildings? Paint phoney windows, complete with cheery flowerpots, on brick facades. Overcrowded city jails? Stick inmates on floating prison barges.

By the end of his tenure he was a celebrity around the world and played himself in a number of movies, including The Muppets Take Manhattan and The First Wives Club and hosting Saturday Night Live. He would also regularly appear in Marvel comics as himself.

After leaving City Hall in 1990, he suffered from a number of health problems. Asked to compose his own epitaph, he said he would like to be remembered for defending the city of New York and loving its people.