MAMARONECK, N.Y. — Standing outside a firehouse here, as 10,000 donated masks were delivered, Rep. Eliot L. Engel confronted the questions that had put his 31-year congressional career in jeopardy.

How did the longest-serving congressman from New York suddenly face complaints of ignoring his district? How did Jamaal Bowman, a former middle school principal who has never run for office, turn Tuesday’s Democratic primary into a pitched battle over who cared more about the north Bronx and southern swath of Westchester County?

“It’s a farce,” Engel said. “People know I bring millions of dollars home from Washington. I know virtually everybody in the district. If there are three people in a room and I’m invited, I’m there.”

Two years after Rep. Alexandria Ocasio-Cortez (D-N.Y.) stunned the political establishment and unseated Joseph Crowley, then the fourth-ranked House Democrat, Engel is trying to fend off the same insurgency from the left. The House Foreign Affairs Committee chairman knew it was coming and has welcomed the help, from the endorsements of Hillary Clinton, Gov. Andrew M. Cuomo and top congressional Democrats to Republican donors funding a super PAC that backs him.

“I’m grateful to anyone who supports me,” said the 73-year-old Engel.

A victory for Engel would humble his party’s growing left wing after its favored candidates came up short in the race for the Democratic presidential nomination. A defeat would reveal the limits of a party establishment that, just a few years ago, could keep its incumbents safe with a simple premise: You know them, so why not keep them?

“It’s like B.C. and A.D. — before AOC and after AOC,” said Ritchie Torres, a liberal state legislator running in the 15th District, which neighbors Engel’s. “In the post-AOC world, incumbency is no longer an entitlement, no longer a guarantee of elected office.”

The primary race between Engel and Bowman, who is African American, comes amid the novel coronavirus pandemic, the resulting recession and civil unrest over police brutality — the latter triggering a moment of national reckoning about racial injustice that is causing voters to take a hard look at candidates.

“We would be remiss not to have leadership of the future to represent this district,” said state Sen. Alessandra Biaggi (D), a rising party star whose grandfather once held Engel’s seat, when she unendorsed the congressman to support Bowman. “When the world changes, you have to be able to update your thinking.”

In 2018, Ocasio-Cortez was one of dozens of first-time candidates recruited by Justice Democrats, a group that grew out of the presidential campaign of Sen. Bernie Sanders (I-Vt.). Most of those candidates lost, but Ocasio-Cortez won and, overnight, became one of the best-known figures in the party.

She had won a low-turnout race with a powerful formula: She was a Latina in an increasingly Latino district and a democratic socialist in a place where white voters leaned far to the left. Crowley had been a good fit for the seat in 1998, and an awkward fit two decades later. A combination of organization, demographics and a compelling personal story pushed Ocasio-Cortez over the top.

“It’s time to more seriously contest safe blue Democratic primaries,” wrote Sean McElwee, the founder of the liberal think tank Data for Progress, after the midterms were over. “Incumbents like Eliot Engel who represent increasingly diverse districts but hold centrist views on key issues should face real electoral competition.”

That became the model, shared by many left-wing groups, to move the Democratic Party in their direction. Engel’s district, which starts at the edge of the Bronx and covers much of suburban Westchester County, does not look exactly like the incumbent; less than half of its residents are white, and one in three are black.

Whoever wins the Democratic primary will be heavily favored in November in a district Clinton won with 75 percent of the vote in 2016.

“We knew a year ago that most voters didn’t have strong views one way or another about Eliot Engel and many also felt that he was pretty absent,” said Justice Democrats spokesman Waleed Shahid. “We knew we could put together a majority ‘Obama coalition’ of people of color, young people, and older white liberals in this district to win.”

That led activists to Bowman, the 44-year-old founder of a middle school that served disadvantaged students. He had not registered as a Democrat until 2018 — a fact that Engel would find and use against him — but until the pandemic hit, he campaigned vigorously, combining a Sanders-style agenda of Medicare-for-all and green infrastructure spending with the argument that the district needed fresh leadership.

“The thing about being an educator is that you’ve got to be a great learner,” Bowman said in a recent interview, after greeting voters in Co-Op City, one of the district’s most racially diverse neighborhoods. “You’ve got to hit the ground and listen to people, and that’s the way I want to govern.”

Engel has a national profile from his chairmanship and a reputation as someone focused on his district. In 2018, when he faced three challengers — one a deep-pocketed local business leader — Engel emptied his campaign funds and won more than 70 percent of the vote.

“Not once have we called his office and not gotten assistance,” said Jamaal Bailey, a state senator who first met Engel after attending kindergarten with his daughter. “Every time I open my office, I hold a barbecue, and he’s there. So the notion that he’s not been visible is very odd to me.”

Bowman found an opening anyway, pounding Engel over votes that were now toxic for Democrats — against the Obama administration’s nuclear deal with Iran, for the war in Iraq. But his breakthrough came last month, deep into the pandemic, when the Atlantic’s Edward-Isaac Dovere found Engel in his D.C.-area residence and flustered him by asking why he wasn’t in New York.

“I’m in both places,” Engel explained.

Two weeks later brought a worse gaffe, when Engel was caught on a hot microphone urging the organizer of a news conference in his district to let him speak.

“If I didn’t have a primary, I wouldn’t care,” Engel said.

Ocasio-Cortez endorsed Bowman a day later; Biaggi did too.

“Support throughout the district and across the country has grown exponentially since that moment,” Bowman said. “The fundraising numbers are astounding.”

In debates and in a recent interview, Engel criticized the rush of support for Bowman and the idea that the challenger was more closely tied to the district. He challenged “people on high” for trying to skew the race, and compared the attacks against him to McCarthyism, unanswerable smears.

“He comes out of the blue, he decides he’s going to run for Congress, and that’s his right,” Engel said in Mamaroneck. “But nobody knows him, and nobody has seen him. When Amadou Diallo was shot, I was arrested, protesting what the police had done. When Ramarley Graham, a young man in my district, was shot by the police, his family asked me to speak at his funeral. So, I’m no Johnny-come-lately on issues of social justice.”

Diallo was an unarmed West African immigrant who was shot and killed by four New York City police officers in 1999.

Two years ago, encouraged by Crowley’s strong internal polling, national Democrats largely stayed out of his race. That’s not the case for Engel. House Speaker Nancy Pelosi (Calif.), House Majority Whip James E. Clyburn (S.C.) and top committee chairmen have endorsed Engel. So has Senate Minority Leader Charles E. Schumer (N.Y.), who initially told Capitol Hill reporters that he was neutral in the race.

Engel also has gotten a boost from Democratic Majority for Israel, seeing a defeat for the reliably pro-Israel congressman as a grave threat, and potential victory for the country’s critics. The group’s advertising does not mention Israel, focusing instead on an old tax debt that Bowman has since paid off. Other pro-Israel groups are more explicit, warning Jewish voters that they could lose a powerful ally to someone whose views on the American-Israel relationship are less well-known.

“Why are they targeting him?” Jack Rosen, the president of the American Jewish Congress, asked Jewish Insider. “The only differentiator is Israel.”

On a campaign trail limited by the pandemic, Israel doesn’t often come up. On Tuesday morning, as Bowman talked to voters in Co-Op City, one supporter of Engel challenged him to debunk the unpaid-taxes story, but the rest said they were happy to see him. Augusta Terzol, 61, said she had always voted for Engel but would happily vote to give the district a new voice in Congress.

“Eliot Engel is responsive, but he usually sends representatives,” Terzol said. “We don’t see him much in Co-Op City.”

Two days later, the congressman joined Bailey for an important local campaign stop: Co-Op City.