Zohran Mamdani, 34, has won New York City's race for mayor in a contest that rallied young voters and sparked debate about the future direction of the US Democratic Party.

Ugandan-born Mamdani, a Democrat, beat former New York Governor Andrew Cuomo, running as an independent, to become the youngest person in over a century to lead the largest city in the US.

My friends, we have toppled a political dynasty, the self-described democratic socialist told the crowd during a victory speech.

Mamdani made affordability the central message of his campaign, pledging to expand social programs paid for by new taxes on high earners and corporations.

In overnight projections from CBS, Mamdani had secured 50.3% of the vote, compared with Cuomo's 41.6%. Republican Curtis Sliwa had just over 7%.

Mamdani's victory raises questions about the future of the Democratic Party, where his leftist approach could signify a shift towards more progressive policies amid criticism from traditionalists.

The future is in our hands, he said, pledging to create a government that works for everyone.