The Democratic Party’s left-wing insurgency found its limits Tuesday night, with voters favoring establishment candidates over more liberal challengers in almost every closely watched race across several states.

In Michigan, former state senator Gretchen Whitmer easily won the Democratic nomination for governor over Abdul El-Sayed, a doctor backed by Sen. Bernie Sanders (I-Vt.) who was vying to become the country’s first Muslim governor.

In suburban House districts across the Midwest, left-wing candidates lost to Democrats backed by party leaders, abortion rights groups and labor unions.

And in St. Louis, where party giant-slayer Alexandria Ocasio-Cortez traveled to help another young insurgent candidate topple an incumbent, Rep. William Lacy Clay (D-Mo.) cruised to an easy primary win over challenger Cori Bush.

Six weeks after Ocasio-Cortez stunned Rep. Joseph Crowley (D-N.Y.), signs of a tea-party-like movement in the Democratic Party that would throw winnable races to far-left candidates appear to be fading. Instead, the party’s establishment has embraced ideas like expanding the Affordable Care Act, shrinking the space between its leaders and its disrupters.

“Trump has been the great doctor, stitching up our scars and healing us organically,” said Washington Gov. Jay Inslee, chairman of the Democratic Governors Association.

The party’s centrists, who had bemoaned Crowley’s defeat, saw Tuesday night as a turning point. Whitmer, who ran on her record of expanding Medicaid in Michigan — and a memorable promise to “fix the damn roads” — will now lead an all-female ticket in a swing state that Hillary Clinton narrowly lost.

Candidates backed by Emily’s List, which endorses women and sometimes clashes with the left, bested left-wing challengers in three southeast Michigan districts; at least two are seen as toss-ups in November. Early Tuesday evening, just one Sanders-backed candidate in a competitive primary was in the lead; Brent Welder, a labor lawyer running in Kansas’s 3rd Congressional District, benefited from a crowd of five less-liberal candidates who split the vote.

“This is a fantastic night for centrist Democrats,” said Jim Kessler, senior vice president for policy at the center-left Third Way think tank. “We nominated the right candidates who can win House seats and governor’s mansions for the Democratic Party. There’s a quiet enthusiasm in the middle. There’s a quiet voice that people are not hearing in the media, but it’s loud at the ballot box.”

The party’s left flank, meanwhile, has bristled at suggestions that it’s spoiling anything for 2018. Since winning her primary, Ocasio-Cortez campaigned for Democrats in California, Kansas, Michigan and Missouri; she also addressed liberal activists at Netroots Nation, the movement’s largest annual conference, held this year in New Orleans.

But even as she intervened against establishment Democrats, Ocasio-Cortez placed her agenda squarely inside the party’s. After campaign stops with El-Sayed, when the candidate said he would support whoever won the primary, Ocasio-Cortez nodded along. She talked less about the abolition of Immigration and Customs Enforcement, an issue elevated by her campaign but still seen as risky for swing-district Democrats.

At the Netroots conference, ­Ocasio-Cortez argued that Democrats would win when they behaved like Republicans — sticking to their values, instead of chasing swing voters.

“They have won while clinging tighter and tighter to their base and convincing us to stray from ours,” Ocasio-Cortez said. “It’s time for us to remember that universal college education, trade school, a federal jobs guarantee, a universal basic income, were not all proposed in 2016. They were proposed in 1940, by the Democratic president of the United States.”

There’s little evidence that the argument inside the Democratic Party has hurt its November prospects. In Tuesday’s special election for Ohio’s 12th congressional district, Democratic nominee Danny O’Connor fought his GOP opponent to a standstill with an electorate that had backed President Trump by 11 points in 2016. In the generic ballot average tabulated by FiveThirtyEight, Democrats held a 5.7-percentage-point lead on June 26. Six weeks later — after plenty of discussion of whether the party was lurching too far left — the lead had inched up to 8 points.

Democrats were also heading to the polls in larger numbers than Republicans. By the end of June, 13.6 million votes had been cast in Democratic primaries, compared with 10.4 million in Republican primaries. Since 2014, the last midterm year, Republican turnout had grown by 24 percent; Democratic turnout had surged by 84 percent. That trend appeared to continue on Tuesday, with Democrats running far ahead of their turnout four years earlier in Kansas and Michigan.

For the party’s labor wing, Tuesday’s results in Missouri provided more reason for optimism. By a nearly 2-1 margin, the state’s voters struck down a “right to work” law passed by the Republican legislature. In an interview, AFL-CIO President Richard L. Trumka said labor unions had proved that even voters who had given Trump a chance in 2016 could be organized against unpopular Republican ideas.

“We know who was behind this,” Trumka said. “We’re going to remind voters of that all the way through November.”

But the Democrats’ internal debate will continue. Eleven more states will hold primaries before the midterms, with many of them featuring battles between the centrist and left wings of the party. On Thursday, two days before Hawaii’s primaries, Ocasio-Cortez will speak in the state on behalf of Kaniela Ing, a member of the Democratic Socialists of America who is running for the House. In an interview, he said his rivals had made the race tougher by attempting to mirror the left’s most popular issues, like Medicare for all.

“It’s difficult to get the message out there, especially when my opponents say the same thing as me in public, and something else to donors behind closed doors,” Ing said. “It means a lot to have Alexandria coming out here.”