If Ms. Comstock loses, it will not be out of complacency. On Saturday, her 59th birthday, her schedule included stops at an Indian-American community event and a Bangladeshi-American soccer tournament. “I am going to celebrate my birthday after 8 or 9,” she said between stops.

Ms. Comstock said she is well known in her district, and has delivered on several legislative priorities of minority business and faith communities, relationships she will need to help her overcome antipathy toward the president. “I think we have a sophisticated electorate that understands that I am my own person,” she said.

For instance, she said she opposed travel restrictions based on immigrants’ faith, a break from Mr. Trump’s call for a Muslim ban. “I don’t support anything on the basis of religion,” she said. “It needs to be on the basis of national security.”

Matt Gorman, a spokesman for the National Republican Congressional Committee, said the party still had confidence in Ms. Comstock, even in the face of a recent poll that showed her trailing by 10 percentage points. “We plan to play in this race,” he said.

When asked if the committee would continue to put in money, Mr. Gorman noted that it had reserved a substantial advertising buy but added, “Right now, we have nothing to announce either way.”

At the mosque in Sterling, thousands of Muslims show up for Friday prayers, and it is common for politicians to speak after services, or for groups to conduct voter registration or petition drives. Ms. Comstock’s Democratic opponent, Jennifer Wexton, a state senator, attended the same Eid services as Ms. Comstock this month. Ms. Wexton has the strong backing of the state’s top Democrats, including Gov. Ralph Northam and Senators Tim Kaine, who is also up for re-election, and Mark Warner.