US congressman Dan Goldman has been defeated in a New York primary election, capping a clean sweep for candidates backed by New York's democratic socialist Mayor Zohran Mamdani.

Goldman was beaten by progressive challenger Brad Lander in New York's 10th congressional district in a contest that laid bare the party's divisions over the Israel-Gaza war.

Lander has accused Israel of genocide in Gaza. Goldman, a two-term incumbent, was backed by pro-Israel groups.

Two other candidates, both democratic socialists endorsed by Mamdani as he seeks to tilt the Democratic party to the left, won their primary races on Tuesday, in a boost for the party's left wing in America's largest city.

Assemblywoman Claire Valdez unseated Brooklyn Borough President Antonio Reynoso in the 7th district.

Darializa Avila Chevalier, a doctoral student who has joined pro-Palestinian protests at Columbia University, won her race in New York's 13th district.

She toppled Adriano Espaillat, who had held the district for five terms and is chair of the Congressional Hispanic Caucus, a body that advocates for legislation and resources for Hispanic Americans.

Mamdani celebrated her win, describing Chevalier as a person "of clarity, of conscience and of conviction".

Lander, who was also endorsed by Vermont's democratic socialist Senator Bernie Sanders, easily beat Goldman by 65.7% to 34.1%, with most votes counted.

He also received praise from Mamdani, who touted Lander's "vision of politics that is more than what we've seen for so long".

In a post on X after the results, Lander said his victory showed that the people of his district covering Lower Manhattan and part of Brooklyn "want leadership ready to fight, not fold, against authoritarianism".

The former New York City comptroller's bid against Goldman, who was first elected to Congress in 2022, was seen as a test of Mamdani's political influence.

Goldman said he had called Lander to congratulate him, according to the BBC's US news partner CBS.

"Tonight, the voters of 10th District have spoken. While this is not the outcome I worked so hard for, I respect their decision," Goldman said.

US President Donald Trump called Goldman "weak and pathetic" in the aftermath of the race, adding that the congressman "just lost, BIG!"

Goldman is an heir to the Levi Strauss denim fortune

Goldman, an heir to the Levi Strauss denim fortune, won plaudits from his party for leading the first impeachment inquiry of Trump in 2019.

But his defence of Israel sparked a backlash from some in New York, including a Brooklyn coffee shop that posted on social media over the weekend that the congressman was not welcome there.

Goldman visited Poetica Coffee in Williamsburg, Brooklyn, with his seven-year-old daughter on Sunday, leading the coffee shop to post that it doesn't "serve racists, fascists, homophobes, genocide enablers or anyone in between". The post was later deleted. Both Lander and Goldman are Jewish.

In New York's affluent 12th district, Jack Schlossberg, the grandson of former President John F Kennedy, lost his election.

Jack Schlossberg is a political newcomer known for his quirky social media posts

Schlossberg, 33, was defeated by assemblymember Micah Lasher in a crowded race to succeed congressman Jerry Nadler. Lasher was an aide to Nadler.

Schlossberg, the son of Caroline Kennedy, is a Vogue correspondent, Harvard Law School graduate and political newcomer known for his quirky social media posts.

Another also-ran in the 12th district was George Conway, the conservative lawyer who set up an anti-Trump group, the Lincoln Project. He managed to win only about 6% of the vote.

Mamdani made no endorsement in that race.

The mayor said earlier on Tuesday: "It's not just a question of electing more Democrats. It's a question of electing better Democrats.

"When I look at these candidacies, I see in them a willingness to also put working people back at the heart of our politics."

But establishment Democrats in Washington are concerned that the left-wing candidates might not appeal to swing voters in this November's midterm elections.

All three candidates backed by Mamdani have vowed to "abolish ICE" and "tax the rich", and they have accused Israel of genocide, which it denies.

Hakeem Jeffries, the Democratic leader of the House of Representatives, said of Mamdani: "We have agreed to strongly disagree.

"A handful of primaries that go in one direction or the other, in a given state or two, aren't going to reshape who we are as House Democrats."