Edward I. Koch, the former congressman and New York mayor whose wisecracking pugnacity embodied the city he led back from the edge of bankruptcy in the 1970s, died Friday in Manhattan of congestive heart failure, a spokesman said. He was 88.

In three terms as New York’s chief executive from 1978 through 1989, the Democrat’s touchstone achievement was to help revive a city that had defined urban dysfunction.

It was Mr. Koch’s quote-
machine of a persona — his unbridled candor and unyielding chutzpah — that made him a dominant character in a city packed with them.

“How’m I doing?” the mayor liked to bellow as he gallivanted up and down city streets, bald pate bobbing, his arms raised above his lanky frame. He spoke in a whiny, nasal voice that was as New York as the screech of an A train.

In recent years, Mr. Koch had a heart attack and quadruple bypass surgery. He was admitted to New York-Presbyterian/Columbia University Medical Center this week and died there about 2 a.m. Friday.

The former mayor, always known for his timing, died on the day “Koch,” a documentary about him, was to open at theaters in New York.

“New York City lost an irrepressible icon,” New York Mayor Michael R. Bloomberg (I) said. “Ed helped lift the city out of its darkest days and set it on course for an incredible comeback.”

After an unsuccessful bid to be mayor in 1973, Mr. Koch ran again four years later. He sought the Democratic nomination in a field that included incumbent Abraham Beame, the loquacious Rep. Bella Abzug and the largely unknown Mario Cuomo.

The race was defined by a serial killer known as Son of Sam and a midsummer blackout that triggered widespread looting and made the city a symbol of urban ills.

Against this tumult, Mr. Koch brandished the slogan “A Liberal With Sanity.” He embraced the death penalty as a way of cultivating the political center. Victorious, he rode a city bus to his swearing-in ceremony.

As mayor, Mr. Koch inherited an estimated deficit of $1 billion. Incurring the wrath of unions, he trimmed the payrolls and stabilized the city’s finances. By 1983, New York’s surplus was $500 million.

In his first two terms, Mr. Koch expanded public housing, encouraged development, and restored services.

During a 1980 subway strike, the mayor stood on the Brooklyn Bridge, cheering on commuters forced to hoof it to work. “We’re not going to let these bastards bring us to our knees!” Mr. Koch shouted, referring to the strikers. “People began to applaud,” he recalled later. “I knew I was on to something.”

When his first term ended, Mr. Koch was so popular that the Democratic and Republican parties both endorsed him for reelection. Time magazine put him on its cover, his picture floating above the city’s skyline.

Douglas Muzzio, a professor at New York’s Baruch College, called Mr. Koch the “quintessential New Yorker. He was bigger than life, and had the personality and ego to prove it.”

Riding his popularity, Mr. Koch ran for governor in 1982, but his campaign foundered after Playboy magazine published an interview in which the mayor dismissed suburban living as “sterile” and rural America as a “joke.”

Troubling times

Over the course of his three terms as mayor, Mr. Koch faced three issues that threatened the social fabric of New York and other large cities: homelessness, AIDS and the spread of crack cocaine.

While AIDS activists at the time chided the mayor, saying he was ineffectual, Mr. Koch cited the more than $400 million in government spending he had directed toward the crisis, the housing he ordered built for AIDS patients and his opposition to AIDS discrimination.

His mayoralty also was defined by several racially charged crimes, including one in 1984 in which Bernhard Goetz, a white man dubbed the “Subway Vigilante” in headlines, shot four black men he believed were about to mug him on a subway train. In 1989, a group of black and Hispanic teenagers were accused of raping and beating a white woman jogging in Central Park, an attack that Mr. Koch branded “the crime of the century.” The convictions of the men were later overturned.

The worst personal crisis Mr. Koch would face was in his third term, after he won reelection in 1985.

Corruption scandals impaled many of his political allies, one of whom, Donald Manes, the Queens borough president, committed suicide with a kitchen knife as federal investigators probed allegations that he took bribes. Rudolph W. Giuliani, then a U.S. attorney, led the prosecution, a role that helped launch a political career that culminated in two terms as mayor.

Although Mr. Koch was never implicated, he said that the scandals were the darkest days of his mayoralty. “I said to myself, ‘Is this how I’m going to be remembered?’ ” he said. “I went into a state of depression that no one was aware of.”

New Yorkers grew tired of the mayor’s apparently unceasing need to share his opinions on everything from life in the Soviet Union (“The pits,” he said) to an assessment of his own physique (“I’m a Greek God”).

During the 1988 presidential campaign, he caused a kerfuffle when he said Jews would be “crazy” to vote for the Rev. Jesse Jackson because Jackson had voiced support for Palestinian leader Yasser Arafat. The mayor’s remark became fodder for critics who derided him as racially polarizing.

The following year, Mr. Koch was defeated in the Democratic primary by David N. Dinkins, who then beat Giuliani during the general election. Dinkins became New York’s first black mayor.

Mr. Koch said his most significant achievement was burnishing the city’s image at a time when New York, with its graffiti-splattered subways and rampant crime, was a national punch line.

“When I came in, people would say they were from Long Island because they were too ashamed to say they were from the city,” Mr. Koch said. “I gave them back their morale.”

Son of a furrier

Edward Irving Koch was born Dec. 12, 1924, in the Bronx, the son of a Jewish immigrant furrier who moved the family to Newark during the Depression. Mr. Koch attended City College of New York but left when he was drafted into the Army during World War II. After his discharge, he received a law degree from New York University.

While practicing law in Manhattan, Mr. Koch became active in a reform group that sought to end the old machine politics in New York.

He scored his first significant political victory in 1963, ousting Carmine DeSapio, an entrenched Tammany Hall politico, as district leader in Greenwich Village. Mr. Koch served on the City Council before winning a seat in the House of Representatives in 1968.

During the 1977 mayoral campaign, Mr. Koch’s otherwise amiable relationship with Mario Cuomo soured when unsigned campaign posters cropped up that read “Vote for Cuomo, Not the Homo,” an allusion to widespread rumors about Mr. Koch’s sexual orientation.

Although Cuomo denied responsibility for the signs, Mr. Koch blamed him and his son, Andrew, who worked on that campaign and is now New York’s governor. Mr. Koch said in later years that the episode tarnished his view of the Cuomos.

Mr. Koch never married and refused to answer questions about his sexual orientation. Still, he sought to neutralize speculation during the 1977 race by campaigning alongside Bess Myerson, the first Jewish woman to win the Miss America title, with whom he was often seen holding hands.

Although Mr. Koch claimed fatigue when he left City Hall, he never grew tired of attention. He wrote novels, memoirs, newspaper columns and movie reviews. He hosted radio and television shows, including “Saturday Night Live.”

Mr. Koch rarely liked to venture far from the city. In 2008, he announced that he had bought a burial plot in New York and planned to spend eternity in the city of his birth.

“The idea of leaving Manhattan permanently irritates me,” he said.