DETROIT — By the time Rashida Tlaib was finished, not a dry eye remained in the room.

“I want people across the country to know that you don’t need to sell out,” Ms. Tlaib said early Wednesday morning. “You don’t have to change who you are to run for office — and that is what this country is about.”

Ms. Tlaib is poised to become the first Muslim woman ever elected to Congress, after she narrowly defeated Brenda Jones, Detroit’s City Council president, in a Democratic primary race to succeed longtime Representative John Conyers Jr. in Michigan’s 13th Congressional District. She will run unopposed in November. In a separate Democratic primary contest for a special election to serve the remaining months of Mr. Conyers’s term, Ms. Jones prevailed over Ms. Tlaib on Wednesday afternoon, according to The Associated Press.

Ms. Tlaib, a former Michigan state legislator, Detroit native and daughter of Palestinian immigrants, was so cautious about celebrating her victory that she waited until every vote was counted — and long after The Associated Press had called the race in her favor — to begin her celebrations at almost 3 a.m.