NEW YORK (AP) -- When Ed Koch was mayor, it seemed as if all of New York was being run by a deli counterman. Koch was funny, irritable, opinionated, often rude and prone to yelling.
And it worked, for a while at least.
With a Bronx-born combination of chutzpah and humor, Koch steered New York back from the brink of financial ruin and infused the city with new energy and optimism in the 1970s and '80s while racing around town, startling ordinary New Yorkers on the streets by asking, "How'm I doing?" He was usually in too much of a hurry to wait for an answer.
Koch died of congestive heart failure Friday at 88, after carefully arranging to be buried in Manhattan because, as he explained with what sounded like a love note wrapped in a zinger: "I don't want to leave Manhattan, even when I'm gone. This is my home. The thought of having to go to New Jersey was so distressing to me."
Fond tributes poured in from political allies and adversaries, some of whom were no doubt thinking more of his earlier years in City Hall, before many black leaders and liberals became fed up with what they felt were racially insensitive and needlessly combative remarks.
The Rev. Al Sharpton said in a statement that although they disagreed on many things, Koch "was never a phony or a hypocrite. He would not patronize or deceive you. He said what he meant. He meant what he said. He fought for what he believed. May he rest in peace."
During his three terms in office from 1978 to 1989, New York City climbed out of its financial crisis thanks to Koch's tough fiscal policies and razor-sharp budget cuts, and subway service improved enormously. To much of the rest of the country, the bald, paunchy Koch became a celebrity, the embodiment of the brash, irrepressible New Yorker.
He was quick with a friendly quip and a devastating putdown, and when he got excited or indignant -- which was often -- his voice became high-pitched. During his time in office and beyond, he dismissed his critics as "wackos," feuded with developer Donald Trump ("piggy") and fellow former Mayor Rudolph Giuliani ("nasty man"), lambasted the Rev. Jesse Jackson, and once reduced the head of the City Council to tears.
"You punch me, I punch back," Koch once observed. "I do not believe it's good for one's self-respect to be a punching bag."
Koch's favorite moment as mayor, fittingly, involved yelling. During a transit strike that brought the city's subways and buses to a halt in 1980, he strode down to the Brooklyn Bridge to rally commuters who were forced to walk to work.
"I began to yell, 'Walk over the bridge! Walk over the bridge! We're not going to let these bastards bring us to our knees!' And people began to applaud," he recalled many years later.
New Yorkers eventually tired of Koch.
Homelessness and AIDS soared in the 1980s, and critics charged that City Hall's response was too little, too late. Koch's latter years in office were marked by scandals involving those around him and rising racial tensions, stoked in part by Koch himself. In 1989, he lost a bid for a fourth term to David Dinkins, who went on to become the city's first black mayor.
On Friday, Dinkins called the former mayor "a feisty guy who would tell you what he thinks."
"Ed was a guy to whom I could turn if I wanted a straight answer," he told Fox 5 News.
In a statement, Mayor Michael Bloomberg said the city "lost an irrepressible icon" and called Koch its "most charismatic cheerleader."
"Through his tough, determined leadership and responsible fiscal stewardship, Ed helped lift the city out of its darkest days and set it on course for an incredible comeback," Bloomberg said.
Koch's mark on the city has been set in steel: The Queensboro Bridge was renamed in Koch's honor in 2011. Coincidentally, a documentary about the mayor titled "Koch" opened nationwide on the very day of his death. After viewing a final cut last summer, Koch applauded and congratulated the filmmaker.
A lifelong bachelor who lived in Greenwich Village, Koch championed gay rights, taking on the Roman Catholic Church and scores of political leaders. His own sexual orientation was the subject of speculation and rumors. During his 1977 mayoral campaign against Mario Cuomo, posters that read "Vote for Cuomo, Not the Homo" mysteriously appeared in some neighborhoods.
Koch 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."
Koch was proudly Jewish and an outspoken supporter of Israel, willing to criticize anyone, including President Barack Obama, over decisions Koch thought could indicate any wavering of support.
"Jews have always thought that having someone elevated with his head above the grass was not good for the Jews. I never felt that way," he said on a WLIW television program, "The Jews of New York." "I believe that you have to stand up."
After leaving office, he continued to offer his opinions as a political pundit, movie reviewer, food critic and judge on "The People's Court." Even in his 80s, Koch exercised regularly and worked as a lawyer.
Describing himself as "a liberal with sanity," Koch pursued a fearlessly independent course. When President George W. Bush ran for re-election in 2004, Democrat Koch crossed party lines to support him and spoke at the GOP convention. He also endorsed Bloomberg's re-election efforts at a time when Bloomberg was a Republican.
"I'm not the type to get ulcers," he wrote in "Mayor," his autobiography. "I give them."
Edward Irving Koch was born in the Bronx on Dec. 12, 1924, the second of three children of Polish immigrants. During the Depression the family lived in Newark, N.J.
The future mayor worked his way through school, checking hats, working behind a delicatessen counter and selling shoes. He attended City College and served as a combat infantryman in Europe during World War II, earning his sergeant stripes.
He received a law degree from New York University in 1948 and began practicing law in Greenwich Village, where he began his political career as a member of a group of group of liberal Democratic reformers. He defeated powerful Democratic boss Carmine DeSapio, whose roots reached back to the corrupt Tammany Hall political machine, in a race for district leader.
Koch was elected to the City Council and then to Congress, serving from 1969 to 1977 as representative for the "Silk Stocking" district that was then known for its millionaire Park Avenue constituency.
The liberal Koch was the first Democrat to represent the district in 31 years. But his politics edged to the center of the political spectrum during his years in Congress and pulled to the right on a number of issues after he became mayor.
His answer to the war on drugs? Send convicted drug dealers to concentration camps in the desert. Decaying buildings? Paint phony windows, complete with cheery flowerpots, on brick facades. Overcrowded city jails? Stick inmates on floating prison barges.
With New York City in dire financial condition in 1977, Koch defeated Mayor Abe Beame and Cuomo in the Democratic primary to win his first term in City Hall. He breezed to re-election in 1981 and 1985, winning an unprecedented three-quarters of the votes cast. At the time, he was only the third mayor in city history to be elected to three terms.
In 1982, he made a run for governor against then-Lt. Gov. Cuomo. But his bid blew up after he mouthed off about life outside his hometown.
"Have you ever lived in the suburbs?" Koch told an interviewer about a possible move to Albany. "It's sterile. It's nothing. It's wasting your life." He said life in the country meant having to "drive 20 miles to buy a gingham dress or a Sears, Roebuck suit."
It cost him the race, but it convinced many of the 8 million city residents that Koch belonged in New York.
Koch's third term was beset by corruption scandals. Queens Borough President Donald Manes, a close ally, committed suicide in 1986 after resigning over kickback and patronage allegations. The Bronx Democratic boss and others were also tarred. Koch's commissioner of cultural affairs, former Miss America Bess Myerson, stepped down after being accused of trying to influence the judge in a court case involving her boyfriend.
Koch fell out with many black voters for purging anti-poverty programs and making comments that many considered insensitive, such as saying that busing and racial quotas had done more to divide the races than to achieve integration.
He also said Jews would be "crazy" to vote for Jackson during the civil rights leader's 1988 presidential campaign after Jackson referred to New York as "Hymietown" and called for a Palestinian homeland in Israel.
It didn't help that Koch's combativeness came during an era of heightened racial unrest, first after the 1986 death of a black youth at the hands of a white gang in Howard Beach and three years later after a black teen was shot to death in Brooklyn's tough Bensonhurst neighborhood by a group of whites.
Koch later said the simmering racial tensions didn't lead to his defeat. "I was defeated because of longevity," he said. "People get tired of you. So they decided to throw me out." But he also once said that his biggest regret as he left office was that "many people in the black community do not perceive that I was their friend."
On Friday, Jackson said in a statement that Koch's "leadership and legacy will never be forgotten in New York City, New York state or our nation."
Koch wrote 10 nonfiction books, including the best-seller "Mayor," ''Politics" and "His Eminence and Hizzoner," written with Cardinal John O'Connor. He also wrote four mystery novels and three children's books.
He also played himself in the movies "The Muppets Take Manhattan" and "The First Wives Club" and hosted "Saturday Night Live." In 1989's "Batman," the character of Gotham City's mayor bore a definite resemblance to Koch.
At age 83, Koch paid $20,000 for a burial plot at Trinity Church Cemetery, at the time the only graveyard in Manhattan that still had space. He had his tombstone with the last words of Daniel Pearl, the Wall Street Journal reporter kidnapped and beheaded by Islamic militants: "My father is Jewish, my mother is Jewish, I am Jewish."
It also includes an epitaph he wrote: "He was fiercely proud of his Jewish faith. He fiercely defended the City of New York, and he fiercely loved its people. Above all, he loved his country, the United States of America, in whose armed forces he served in World War II."
The funeral will be Monday at Temple Emanu-El in Manhattan. Koch is survived by his sister, Pat Thaler, and many grandnieces and grandnephews.
Associated Press writer Samantha Gross contributed to this report.