That's what we said when Giuliani ran against (light-skinned black) David Dinkins, who was Bronx Borough President. The first time, the Democratic machine stole a victory. The second time, Dinkins had run NYC so far into the ground in street crime, general filth, businesses leaving in droves, and financial mismanagement and graft, that Giuliani managed to beat the steal and win two terms. He transformed New York City with common sense and Trump-like toughness--in quality of life, business investment, crime stats, and people rushing to move back to a great city. It was probably the best performance by a mayor, based on competence and results, in a century.
But yes, a lot depends on luck.
New York only had one bad year. When Rudy won, New York was declining for decades.