Standing at his final rally of the 2024 campaign, former President Donald J. Trump in the first minutes after midnight on Election Day used a crude sexist remark to attack Representative Nancy Pelosi, the former House speaker who is one of his longstanding political rivals.

“She’s a bad person,” Mr. Trump said at the Van Andel Arena in Grand Rapids, Mich. “Evil. She’s an evil, sick, crazy —” He made an exaggerated face, his mouth open wide to draw attention to the next syllable: “Bi—”

Then he held up a finger dramatically, feigning that he’d caught himself. “Oh no,” he said. As the crowd of thousands began laughing, Mr. Trump mouthed the word into the microphone. “It starts with a B, but I won’t say it,” Mr. Trump added. “I want to say it.”

As the crowd roared even louder, some of the attendees began to supply the word he’d barely omitted, shouting, “Bitch!”

In the closing days of the race, Mr. Trump has made direct appeals to women as he stares down a gender gap in the polls that has concerned him and his team. He has tamped down mentioning his role in appointing Supreme Court justices who overturned the constitutional right to an abortion, an issue that polls show to be a top concern to female voters.

Yet at the same time, Mr. Trump has used misogynistic language to refer to Vice President Kamala Harris and has fostered an environment at his rallies where speakers and attendees feel comfortable making the kind of gendered insults that, in another political era, would have been unthinkable to say in public.

Vice President Kamala Harris has been the target of misogynistic language from the former president.Credit…Erin Schaff/The New York Times

Mr. Trump has argued that Ms. Harris, who would be the first female president if she wins, lacks the stamina and intelligence to lead the country. He appeared to embrace a remark shouted by a rallygoer that insinuated Ms. Harris was a prostitute. And he voiced some approval of an audience member’s idea to put Ms. Harris in the ring with the boxer Mike Tyson.

In Reading, Pa., Mr. Trump was telling an off-topic aside on Monday about Mr. Tyson when a man in the crowd used it as an opportunity to demean Ms. Harris. “Oh, he says, ‘Put Mike in the ring with Kamala,’” Mr. Trump said. “That will be interesting.” The crowd cheered.

He used violent imagery as he denounced Liz Cheney, the Republican former congresswoman who has become an outspoken Harris surrogate, as a coward. “Let’s put her with a rifle standing there with nine barrels shooting at her, OK?” Mr. Trump said last week during an interview with Tucker Carlson. “Let’s see how she feels about it. You know, when the guns are trained on her face.”

And even as Mr. Trump has said that his advisers have told him to stop saying he would protect women, he went a step further last week by saying he would protect them “whether the women like it or not.”

The Harris campaign cast those remarks as paternalistic and sexist. “He simply does not respect the freedom of women or the intelligence of women to know what’s in their own best interest and make decisions accordingly,” Ms. Harris said at a rally in Phoenix. “But we trust women.”

The Trump campaign did not immediately respond to a request for comment.

Mr. Trump’s remarks have opened the door for his allies to express their own crude, sexist views, including at his campaign events. At his rally in Madison Square Garden on Oct. 27, one speaker likened Ms. Harris to a prostitute being directed by “pimp handlers.” Another called Hillary Clinton, Mr. Trump’s 2016 opponent, a “sick son of a bitch.”

Elon Musk’s pro-Trump super PAC ran an ad that dances around one of the most vulgar insults for women in the English language. The ad opened with “Kamala Harris is a C Word.” It eventually revealed the word to be communist. Mr. Musk is one of Mr. Trump’s most vocal and high-profile surrogates, and the former president lauds him at length during his rallies.

Mr. Trump’s running mate, Senator JD Vance of Ohio, responded to President Biden’s remark that appeared to insult Trump supporters as “garbage” by using a similar description of Ms. Harris. “We’re going to take out the trash, and the trash’s name is Kamala Harris,” he told a rally crowd in Atlanta this week.

Mr. Vance has previously broadly disparaged liberal women leaders as “a bunch of childless cat ladies who are miserable at their own lives and the choices that they’ve made.”

The conservative commentator Bill Kristol, who has long been opposed to Mr. Trump, quoted the former president’s remark about Ms. Pelosi and Mr. Vance’s “trash” comment about Ms. Harris on X, and replied, “If you’re voting for Trump-Vance, this is who you’re voting for.”

Senator JD Vance has made remarks that have disparaged women.Credit…Maddie McGarvey for The New York Times

In Mr. Trump’s closing week, his campaign has increasingly brought women to speak as warm-up acts at his rallies and positioned women in the stands behind the stage. Gov. Sarah Huckabee Sanders of Arkansas, the retired racecar driver Danica Patrick and Sage Steele, a former ESPN anchor, have all rallied Mr. Trump’s supporters in the closing weekend.

But the difficulty of Mr. Trump simultaneously making a macho appeal to men while trying not to alienate women was on display at his rally in Pittsburgh the day before the election. He called Megyn Kelly, the former Fox News anchor, to the stage.

Ms. Kelly and Mr. Trump feuded publicly during his first campaign in 2016, when she pressed him about his comments calling women “fat pigs, dogs, slobs.” He responded by attacking her online and telling an interviewer that Ms. Kelly had “blood coming out of her eyes, blood coming out of her wherever.”

But standing in a critical battleground state on Monday, Ms. Kelly defended him from criticism over his comments about protecting women. Then, she closed her pitch to women by expressing her concern for men.

“I’m not into their version of toxic masculinity or new masculinity,” she said of Democrats. “I prefer the old version.”

Chris Cameron contributed reporting.