Incumbent write-in candidate Byron Brown, a Democrat, leads his party’s socialist nominee India Walton by 17 points in the hotly contested Buffalo mayor’s race that is a microcosm of the nationwide ideological rift in the Democratic Party, according to a new poll released Wednesday.

Walton stunned the political world by defeating four-term incumbent Brown in a low-turnout June Democratic primary — the biggest upset since fellow Democratic socialist Rep. Alexandria Ocasio-Cortez toppled ex-Congressman and Queens Democratic Party leader Joe Crowley in the 2018 primary.

AOC stumped on the campaign trail with Walton last weekend.

But Brown is doing a write-in campaign, "Write Down Byron Brown," and the WIVB/Emerson College survey shows him ahead by 17 points among the broader electorate.

AOC THREATENS ‘NO’ VOTE ON INFRASTRUCTURE IF DEMOCRATS DON'T PROVIDE SOCIAL SPENDING BILL TEXT

The poll said 53.8 percent of likely voters support Brown, compared to 36.2 percent of Buffalonians for Walton.

Another 6 percent of voters are undecided and 3.8 percent said they would back someone else. There is a second write-in candidate, Ben Carlisle.

Write-in candidates typically face uphill races and polling the support for such a candidate is dicey. But the WIVB/Emerson poll sought to confront that challenge.

In its question, the pollster asked voters whom they planned to vote for and only gave Walton’s name — the only one on the ballot — and then gave an "undecided option" and an option for "someone else." Those who responded "someone else" had to volunteer Brown’s name for it to be counted in the poll results. There is no Republican candidate on the ballot.

"Considering only 6 percent of voters are currently undecided right now, Byron Brown has a pretty significant lead in the race that may not be able to be overcome by India Walton," Emerson College Polling analyst Isabel Holloway told WIVB.

"Even when we asked those undecided voters who they are leaning towards at this time, they break over 2-to-1 toward someone else rather than India Walton."

Brown has expanded his lead from 10 points in an August poll to 17 points.

The pollster attributed the Brown surge to increased interest and turnout for the general election, as well as attacks on Walton’s leftist politics that have struck a chord with moderate and conservative voters.

Walton defeated Brown by 1,000 votes in the Democratic primary.

But the survey found Brown leading by about 9 points among Democrats in the general election, 49.5 percent to 40.8 percent.

Democratic Buffalo mayoral primary candidate India Walton delivers her victory speech after defeating incumbent Byron Brown, on Tuesday, June 22, 2021 in Buffalo, New York. (Buffalo News)

Republicans are a crucial bloc of what looks like a center-right coalition for Brown. More than 80 percent of Republicans say they’re voting for Brown to just 8 percent for Walton.

"Considering that Walton won the Democratic primary, one would expect her to be winning among registered Democrats in the general election," Holloway said.

CLICK HERE TO GET THE FOX NEWS APP

"However, we found that that is not true. In fact, Byron Brown is leading among registered Democrats. This suggests that Democrats tuned in after the primary election and maybe did not turn out for Byron Brown in the primary but are choosing to do so in the general."

Both Walton, who would become Buffalo’s first female mayor, and Brown are African American.

Walton led among black voters 53 percent to 36.6 percent and had a slight lead among younger voters.

But Brown led by better than 2-to-1 among white voters, had more than 70 percent of support from voters with less than a college degree, and was well ahead among older voters.

The poll surveyed 539 likely voters last weekend and has a margin of error of plus or minus 4.2 percentage points.