MANCHESTER, N.H. — President Trump, who held a campaign rally here just hours before the first-in-the-nation primary, has inserted himself into the Democrats' nominating contest with a fervor that exceeds his predecessors — many of whom were reluctant to directly involve themselves in another party's political selection process.

For Trump, visits to early-voting states allow him to inject his trademark bombast into a crowded and muddled field of Democrats, while also conducting a kind of political warfare against a party that is enduring bouts of disunity and uncertainty at the very moment that Republicans appear most unified behind him.

Before leaving for New Hampshire, Trump wrote on Twitter that he wanted to “shake up the Dems a little bit.” The president also held a rally in Iowa last month ahead of that state’s critical caucuses.

“They always talk about the Democrats, they have enthusiasm, right?” Trump told a crowd at the SNHU Arena here. “We have so much more enthusiasm, it’s not even close. They’re all fighting each other. They’re all going after each other. You got them all over the place. They don’t know what the hell they’re doing. They don’t know what they’re doing. They can’t even count their votes.”

Trump’s campaign argues that the draw of Air Force One, a stable of Cabinet officials and White House aides, and a president known for lively rallies combine to boost Trump’s supporters and deflate his detractors in key states where Democrats are trying to build momentum.

Democrats have tried to capitalize on Trump’s presence as well, using his visits to cast themselves as an alternative to his divisive brand of politics.

Sen. Bernie Sanders (I-Vt.), who has been leading in the polls in New Hampshire, spent considerable time contrasting himself with Trump ahead of the president’s visit Monday.

“I will not be lying to the American people every single day about everything,” Sanders said in Manchester.

Jeff Weaver, a Sanders adviser, said Trump’s visit makes it easier for voters to imagine what a general election would look like.

“Trump’s presence in New Hampshire is an opportunity to contrast Senator Sanders’s agenda against Trump’s record of division and betraying working families,” he said.

A Quinnipiac University poll released Monday found Sanders and several other Democratic candidates beating Trump nationally in a head-to-head matchup.

But the power of incumbency and the fervor of Trump’s political base have presented uncomfortable images for the group of Democrats trying to convince voters they would be the best positioned to defeat the president.

Hours before Trump’s rally in Manchester, hundreds of people lined up in the cold, waiting to get into the arena. The scene mirrored a similar event last month in Des Moines, where the Trump campaign had to turn away supporters after Drake University’s Knapp Center reached capacity. While Democrats have not had crowds as large as the throngs showing up to Trump’s rallies, often many hours in advance, they have seen strong enthusiasm at events.

In Des Moines, Trump used his 80-minute speech to attack several of the Democratic candidates, including former vice president Joe Biden and Pete Buttigieg, the former mayor of South Bend, Ind.

After the caucuses, which were plagued by technical difficulties on the Democrats’ side, Trump reveled in his opponents’ misfortune and praised his 97 percent showing among Iowa Republicans.

Before leaving Washington on Monday, Trump repeatedly referenced the large crowds in Manchester, including by retweeting an ABC News reporter who wrote: “Despite the miserable weather, there are already more people lining up outside the venue of @realDonaldTrump’s rally tonight than you see at most of the events for the Democratic candidates.”

Trump’s campaign has followed suit, with aides and surrogates traveling en masse to early states to tout the president’s record and to handicap the Democratic races.

“If Biden doesn’t win big, I mean, he’s probably in a lot of trouble,” Trump’s son Donald Trump Jr. said last week in West Des Moines, Iowa, just hours before the first-in-the-nation caucuses in which Biden ultimately placed fourth.

Vice President Pence, who toured parts of New Hampshire ahead of Trump’s rally, will travel to Nevada on Feb. 21 for two political events a day before the Democrats’ Nevada caucuses.

“We did the same thing in Iowa, and it’s safe to say you’ll see us around quite a bit,” said Marty Obst, Pence’s top political aide.

Campaign officials said they were pleased with the reception Trump received in Iowa ahead of the caucuses, noting that the president was featured on the front page of the Des Moines Register after his rally.

Trump liked that the Democrats, who spent millions of dollars to compete in competitive and critical first-in-the-nation caucuses, were pushed off the front pages by Trump’s reelection machine, according to the officials.

“The thinking is, if everyone in the world has their eyes on the state, why aren’t we there?” said a campaign official who, like others, spoke on the condition of anonymity to discuss internal deliberations.

While Trump won Iowa by more than nine percentage points in 2016, his narrow 0.4-point loss in New Hampshire has made the state a top target for Trump campaign officials looking for ways to expand the electoral map.

For that reason, Tuesday’s primary — where Trump faces nominal opposition from former Massachusetts governor Bill Weld — is serving as a kind of training ground for the volunteers, campaign aides and supporters Trump is hoping will power his reelection, said Tim Murtaugh, a campaign spokesman.

“We will have dozens of top surrogates in the state and have made tens of thousands of voter contacts by phone and door knocking, recruiting volunteers and continuing to build the Trump army,” Murtaugh said.

The Trump campaign’s effort to counter the Democratic race extended to a “Cops for Trump” gathering on Monday afternoon in Portsmouth, N.H. Pence and White House senior adviser Ivanka Trump both spoke at the event, which was attended by about 200 police officers, before later joining the president in Manchester.

The Trump campaign has been active in New Hampshire for weeks, sending legions of surrogates to the state and booking them on state-based talk radio programs and at local Republican events.

For Trump and his loyalists, New Hampshire holds a particularly special place in their collective political memory: It was his first primary victory and a significant boost that pushed him toward the 2016 Republican nomination. Its industrial history, working-class demographics and independent streak have kept it a prime target for the Trump campaign.

Flashes of Trump’s dominance of the GOP were everywhere as Pence toured the state with Ivanka Trump and Corey Lewandowski, the president’s former campaign manager.

At the Sheraton Portsmouth Harborside Hotel, former New Hampshire GOP senator Kelly Ayotte — who was long an ally of establishment military hawks in the Senate — enthusiastically talked up the president’s record, putting an emphasis on the administration’s foreign policy, such as the president’s decision to order a strike that killed Maj. Gen. Qasem Soleimani, the head of Iran’s elite Quds Force.

Ayotte also cast the Democrats as socialists, taking direct aim at Sanders, who describes himself as a democratic socialist.

“Make no mistake, socialism is on the ballot,” she said.

Pence, who accepted the endorsement of the New England Police Benevolent Association, attacked Sanders over his opposition to the strike that killed Soleimani.

“Today’s Democratic Party has been taken over by radical leftists,” Pence said in Portsmouth.

There were tensions and signs of the nation’s intense political divide. Early on in Pence’s remarks, several protesters started to shout “Trump endangers Jews.” Some police officers in the room, sitting near the disruption, grabbed the protesters’ homemade signs, pulling them out of their hands. The protesters were quickly pulled out of the room by security.

Trump has used his pre-vote rallies to highlight that the Republican Party is unified behind him while Democrats were struggling to rally behind a standard-bearer. He has also tested out attack lines against several of the Democratic candidates, tending to focus most on whichever contender is atop the polls.

Lewandowski, who has served as a senior adviser to Trump’s 2020 bid, said Trump’s willingness to insert himself into the Democratic primary races will ultimately help him in November.

“Donald Trump has once again demonstrated his ability to drive a narrative, coming to New Hampshire and taking the spotlight away from the socialists and reminding America about what he has delivered,” he said. “If the president doesn’t go out and tell his message, nobody will.”

Reis Thebault in Washington and Sean Sullivan in Manchester contributed to this report.