O'Dwyer was born in County Mayo, Ireland and migrated to the United States in 1910, after abandoning studies for the priesthood. He worked as a laborer, then as a New York City police officer, while studying law at night at Fordham University Law School. He received his degree in 1923 and then built up a successful law practice before serving as a Kings County (Brooklyn) Court judge. He won election as the Kings County District Attorney in 1939 and his prosecution of the organized crime syndicate known as Murder, Inc. made him a national celebrity.
In 1945, O'Dwyer received the nomination of the Tammany Hall Democrats and easily won the mayoral election. At his inauguration, O'Dwyer celebrated to the song, "It's a Great Day for the Irish," and addressed the 700 people gathered in Council Chambers at City Hall: "It is our high purpose to devote our whole time, our whole energy to do good work..." He established the Office of City Construction Coordinator, appointing Robert Moses to the post, worked to have the permanent home of the United Nations located in Manhattan, presided over the first billion-dollar New York City budget, created a traffic department and raised the subway fare from five cents to ten cents. In 1948, O'Dwyer received The Hundred Year Association of New York's Gold Medal Award "in recognition of outstanding contributions to the City of New York."
Shortly after his re-election to the mayoralty in 1949, O'Dwyer was confronted with a police corruption scandal uncovered by the Kings County District Attorney, Miles McDonald. O'Dwyer resigned from office on August 31, 1950. President Harry Truman appointed him U.S. Ambassador to Mexico. He returned to New York City in 1951 to answer questions concerning his association with organized crime figures and the accusations followed him for the rest of his life. He resigned as Ambassador on December 6, 1952, but remained in Mexico until 1960.
O'Dwyer's brother Paul O'Dwyer was also a New York City politician, and served as the then-city-wide elected position of City Council President from 1974 through 1977.
William O'Dwyer died in New York City on November 24, 1964, at the age of 74, and was buried in Arlington National Cemetery.