Ghazala Hashmi was on her way to work one winter morning in 2017 when she heard news on the radio that left her in a panic: President Trump’s order banning refugees from certain Muslim countries was making headlines, and she was concerned about the possibility of a Muslim registry being created in the United States .

Ms. Hashmi, who came from India to the United States at the age of 4, pulled up to the community college where she worked, parked her minivan and felt frozen with fear. As a Muslim who had lived in the United States nearly all her life, she wondered, did she still have a place in the country she called home?

She shed those doubts on Tuesday when she became the first Muslim to be elected to the Virginia State Senate, a milestone that comes amid a wave of Muslims running for elected office across the country and increased visibility for Muslim women in politics.

Ms. Hashmi, 55, upset the Republican incumbent to represent a district based in Chesterfield County, which includes suburban Richmond . Her victory helped to flip the Senate on a night that Democrats took control of both chambers and consolidated power across state government for the first time in a generation.