As the laughter subsided, Mr. Rouda asked how many people had been lifelong Democrats. A couple dozen hands went up in a crowd of roughly 200 people.

“How many of you would not have been at a meeting like this if Hillary Clinton had won?” he asked. Then, many more people raised their hands, as murmurs of agreement rippled through the room. He quickly added: “Me neither. President Trump has changed everything.”

Throughout the country, there have been other examples of former Republican or unaffiliated voters jumping into the political ring this year. Of the dozens of first-time Democratic candidates vying for Congress in this year’s midterm elections, there are candidates in Texas, Ohio and North Carolina who until recently were registered as Republicans or Independents. Like Mr. Rouda, many saw themselves as Reagan Republicans, but say the party has steadily strayed from the ideals of the former president (who was also once the governor of California.) They were stunned to see Mr. Trump win the White House, they said, and his presidency has at once activated and radicalized them.

Races like this one represent an essential test for Democrats: Can the party win over moderate, suburban and affluent voters even as it moves toward a more populist bent? Mr. Rouda has said he is in favor of Medicare for All, a $15-an-hour federal minimum wage tied to inflation, along with free tuition at public colleges. While Democrats in many parts of the country are embracing similar policies in an appeal to liberal voters, Mr. Rouda is counting on attracting moderate voters by portraying his support for these policies as fiscally responsible.

Republicans still outnumber Democrats by 10 percentage points in this wealthy district. I n a sign of the challenge Mr. Rouda faces, Ms. Clinton won by just two points and Mr. Rohrabacher easily secured a victory of nearly 17 points in 2016.