As for Mr. Farage, the stakes could not be higher: Either he wins and takes his message from the fringes to the heart of British politics, or he loses and resigns as party chief, spelling a crisis for a movement that has become all but synonymous with his leadership.

A former commodities trader with a smoker’s cough and heaps of pub-counter charisma, Mr. Farage wants Britain to leave the European Union and blames immigrants for everything from scarce primary school places and hospital beds to a shortage of affordable housing.

He also promises to “spot-fine” all those who allow their dogs to foul the sidewalk 80 pounds (about $120).

“I want my country back!” Mr. Farage cried when he turned up in Ramsgate that recent morning.

Ramsgate’s aging, white, working-class population feels left behind by globalization and mainstream politicians on the left and right, said Matthew Goodwin, a professor of politics at Nottingham University. Mr. Farage, he said, “has become a very good articulator for what a certain section of British society feels and thinks.”

One of UKIP’s election posters shows an escalator going up the white cliffs of Dover. A hallmark purple leaflet is blunter: “Open borders for convicted murderers from Europe to come in and out.” In south Thanet, the number of immigrants is below the national average. But that is not how locals perceive it.

“It’s out of control,” Trevor Jarmin, 49, said. He said that he had lost several jobs to Polish workers willing to work for lower wages. Alan Bessant, 59, a former soldier, said his neighbors had trouble getting their children a place in school.