MANCHESTER, N.H. — President Donald Trump made a rare move Thursday night — holding a rally in a state he didn’t win in 2016, New Hampshire.

Trump has spent most of his time as president in the key swing states of Ohio, Florida and Pennsylvania. But his advisers urged him to make a stop in New Hampshire, which he lost by less than 3,000 votes, despite the state's having just four electoral votes.

In an election that could again turn on a razor’s edge, every vote will count. With New Hampshire at the center of the Democratic primaries, the rally gave Trump an opportunity to hit back at Democratic rivals who have been attacking him in the state for months. He took the opportunity to again accuse the party of being full of socialists who want to tear America apart.

“They look down upon the hardworking citizens who truly make our country run,” Trump said of Democrats, though he made only glancing references to potential 2020 rivals such as Sen. Elizabeth Warren of Massachusetts and former Vice President Joe Biden, or to Rep. Ilhan Omar, D-Minn., whose planned trip to Israel was short-circuited on Thursday after presidential tweets urging the government there to deny her entry.

Trump suggested without evidence that the only reason he lost New Hampshire in 2016 was because the election here was stolen from him.

“New Hampshire should have been won last time, except we had a lot of people come in at the last moment, which was a rather strange situation,” Trump told reporters before departing his summer retreat in Bedminster, New Jersey, for the rally in Manchester. “Thousands and thousands of people coming in from locations unknown. But I knew where their location was.”

It was a claim he repeated during the rally. “New Hampshire was taken from us,” he said.

In an hour and a half speech, Trump hit on most of his usual themes — emphasizing the economy and saying New Hampshire had been hit worse than most other states by negative long-term trends.

“You look like central casting for the closing of factories,” Trump said.

New Hampshire, which had a 2.8 percent unemployment rate when Trump took office, has continued to have one of the lowest unemployment rates in the country.

In a week when bond markets flashed what has historically been a major recession warning and the stock market had its worst day of the year to date, the president rolled out both his positive and negative economic pitches, again arguing that if he loses re-election, the stock market will plummet.

“You have no choice but to vote for me, because your 401(k) is down the tubes. Everything’s going to be down the tubes,” Trump said. “So whether you love me or hate me, you’ve gotta vote for me.”