ELKHART, Ind. — Hours before the gym doors opened Thursday night for President Trump’s rally, thousands of his supporters formed a line that snaked through the narrow streets of a working-class neighborhood. Hundreds who couldn’t get inside gathered around outdoor speakers to hear the president.

Trump was upbeat and beaming. He recognized the Republican candidate for Senate, mocked the Democratic incumbent and laid out the stakes of the midterm elections in simplistic but exaggerated terms, warning that Democrats want to raise taxes, get rid of the country’s borders and reduce the number of jobs.

“They fight for all of the things that we don’t stand for,” Trump said. “If we elect more Republicans, we can truly deliver for all of our citizens.”

The rally provided a snapshot look at the role that the president hopes to play in the midterm elections this fall. He has cast this election as a referendum on his presidency and stressed that a vote for a Republican, any Republican, is a vote for Trump.

At rallies, he can directly connect with his strongest supporters and urge them to vote for Republicans. His presidency, he says, is under attack, and no Democrat — even a moderate one — can be trusted. On stage, Trump rarely wastes time detailing the biographies or stances of the candidates he’s promoting. Instead, he talks about his own accomplishments and the ways that Democrats have blocked him from doing more.

White House aides have been reluctant to detail the president’s midterm campaign strategy, and some Republican candidates — especially those running for House seats in suburban areas where Trump’s popularity is often the lowest — have been reluctant to embrace him. Trump has made clear that no one will dictate where he can or cannot host rallies, and he is expected to focus heavily on the 10 states that he won in 2016 that have Democratic senators up for reelection: West Virginia, North Dakota, Montana, Indiana, Missouri, Ohio, Wisconsin, Florida, Pennsylvania and Michigan.

Local Republican officials have mostly welcomed the president’s attention. Anywhere he goes, Trump can do something that’s difficult for most candidates on their own: generate news that dominates local front pages and evening newscasts and gets a huge group of conservatives fired up and eager to vote. On Thursday night, Trump drew attention to Indiana’s candidates for the U.S House — including Greg Pence, the brother of Vice President Mike Pence, who introduced Trump — and called up to the stage Mike Braun, who won the state’s GOP Senate primary Tuesday.

“There was unbelievable enthusiasm,” said Kyle Hupfer, chairman of the Republican Party in Indiana, a state the president won by 19 points in 2016. “I couldn’t ask any more of the president and the vice president than what they delivered.”

That excitement was palpable — and Trump-focused. Many rallygoers wore Trump T-shirts, red campaign hats and clothing featuring or inspired by the American flag. Some had driven in from neighboring states. They danced to the president’s personal playlist, posed for selfies and live-streamed video of their experiences on Facebook.

Representatives from Susan B. Anthony List, which supports candidates opposed to abortion, tried to harness the energy, passing out fliers to recruit paid canvassers who want to “help President Trump defeat Joe Donnelly,” Indiana’s Democratic senator who is considered one of the most vulnerable in the country.

Vic Coffman sipped a beer and watched the spectacle from his front porch with his wife and two neighbors. The 51-year-old, who works at an industrial bakery, voted for Trump in 2016.

“Washington has turned into a big pit of people that just keep doing what the next person’s doing,” said Coffman, an American flag tattoo peeking out from under the sleeve of his white-and-blue Trump T-shirt. “I mean, if you think about: What is insanity? It’s that you keep doing the same thing and expect different results, and that’s what we keep doing. It’s time for a change.”

In Tuesday’s GOP Senate primary, Coffman voted for Rep. Todd Rokita, who campaigned with the Trumpy slogan “Defeat the elite.” Although Braun wasn’t his top choice, Coffman will still vote for him this fall against Donnelly.

“I’m sticking with trying to get Trump some support in the White House so that he can maybe make some changes,” he said.

Trump’s appearance also fired up those opposed to his presidency. About 400 demonstrators gathered near the school gym with homemade signs that focused on Trump, not Braun. As they chanted and sang together, a young man circulated through the crowd and offered to help people register to vote.

At one point, a Trump supporter shouted at the group: “Go home!” A woman yelled back at him: “I am home. We live here, too, sir!”

Inside the rally, the biggest cheers were for Trump, who was welcomed to the stage by a standing ovation that drowned out his walk-on song. “We love you, Truuuuump!” one man bellowed again and again. At least 7,500 people were packed into the gym, and almost all stood through most of the president’s nearly hour-long speech.

Up in the stands, Robert and Tammy Workman cheered on their president. They were excited to also see Braun, whom they voted for Tuesday because he reminds them of the president: Both are business executives, both self-financed their primary campaigns, and both have pledged to drain the swamp in Washington.

“I like the fact that he’s an outsider,” said Tammy Workman, 50, who lives in Nappanee. “Basically, we’re tired of the career politicians. We give you a chance, give you a chance, give you a chance — nothing changes.”

Getting enthusiasm for Trump to translate to votes for Republican congressional candidates is key to the party’s success in November. Hupfer, the state GOP chairman, said officials have been working to stay connected with Trump voters.

“Having the president himself tell that group of voters how important it is is critical, and there’s no substitute for that, really,” Hupfer said. “He has to speak to those folks.”