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 supported him and spoke at the GOP convention. He also endorsed Bloomberg's re-election at a time when Bloomberg was a Republican.
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 of New York and served as a combat infantryman in Europe during World War II.
He received a law degree from New York University in 1948 and began his political career in Greenwich Village as a liberal Democratic reformer, beating the powerful old-school party boss Carmine DeSapio in a race for district leader.
Koch was elected to the City Council and then to Congress, serving from 1969 to 1977 as the representative from the wealthy East Side's "Silk Stocking" district.
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.
Drugs? Send convicted dealers to concentration camps in the desert. Decaying buildings? Paint phony windows with cheery flowerpots on brick facades. Overcrowded jails? Stick inmates on floating prison barges.
With New York 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.
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 the big city.
"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.
Koch's third term was beset by corruption scandals, one of which ended in the suicide of a top party boss in 1986. Also, Koch's friend and 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 saying, among other things, 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.
Racial tensions were running high at the time because of the deaths of two young black men who were set upon by gangs of whites in 1986 and 1989.
Koch later said the simmering 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 said 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 "His Eminence and Hizzoner," written with Cardinal John O'Connor. He also turned out four mystery novels and three children's books.
He played himself in the movies "The Muppets Take Manhattan" and "The First Wives Club" and hosted "Saturday Night Live." In 1989's "Batman," Gotham City's mayor bore a definite resemblance to Koch.
At 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 inscribed with the last words of Daniel Pearl, the Wall Street Journal reporter beheaded by Islamic militants: "My father is Jewish, my mother is Jewish, I am Jewish."
The funeral will be Monday at Temple Emanu-El in Manhattan. Dignitaries including New York City Mayor Michael Bloomberg and Ido Aharoni, the Israeli consul general in New York, will be among the speakers, a person familiar with the arrangements, speaking on condition of anonymity, told the AP.
Koch is survived by his sister, Pat Thaler, and many grandnieces and grandnephews.
Associated Press writer Samantha Gross contributed to this report.