There were two big races in Democratic politics in Massachusetts on Tuesday, and neither turned into a major upset — even when a Kennedy was the one trying to do the upsetting.

Before Rep. Joe Kennedy challenged Sen. Edward J. Markey for the Senate and lost, a member of the Kennedy family had never lost a race in Massachusetts. Similarly, the powerful chairman of the House Ways and Means Committee, Rep. Richard E. Neal, faced a strong primary challenger but prevailed.

In their own ways, however, these Massachusetts primaries emboldened the left wing of the Democratic Party as much as some big wins this summer, including toppling another House chairman in New York, Rep. Eliot L. Engel.

Rep. Alexandria Ocasio-Cortez (D-N.Y.) is probably right: It’s now more difficult for House Democratic leaders to tell the left to stop challenging Democratic members of Congress.

That’s primarily because in the Massachusetts Senate race, House Speaker Nancy Pelosi (D-Calif.) was the one cheering the Democratic challenger, Kennedy. She surprised the political world by endorsing him when Kennedy himself could not quite explain why he was running. (There’s almost no daylight between him and Markey on policy, and Markey was not seen as particularly weak. In fact, Markey sponsored the Green New Deal with Ocasio-Cortez, earning her endorsement and making him the left’s favorite in this race.)

There was clearly ambition. Some have speculated that Kennedy, 39, eventually wants to run for president, and a Massachusetts Senate seat is as good a perch as any from which to do so. (See most recently John F. Kerry.)

So Pelosi firmly planted herself on the side of the challenger. And with that dynamic, by keeping 74-year-old Markey in his seat, the left can actually claim a win over the Democratic establishment. It rounds out a notably good summer for this wing of the party. It has overthrown three sitting Democratic members of Congress, kept one in against Pelosi’s wishes and now arguably has more freedom in the next election cycle to keep trying.

Where the left-wing Democrats fell short Tuesday night was in their biggest attempt of all in 2020 — to take out Neal. With 88 percent of the vote in at 2 a.m. Wednesday, the Associated Press declared him the winner over challenger Alex Morse, the mayor of the small town of Holyoke, who also had Ocasio-Cortez’s endorsement and support from key left-wing groups.

To try to prevent this exact kind of thing from happening, House Democrats’ campaign arm last year prohibited its vendors from working with challengers to Democratic incumbents. But liberal groups such as Indivisible still found ways to raise money and spend it against members of Congress. They went on TV against Neal and paid for digital and mail ads for weeks leading up to the race.

Morse got 50,000 votes, or at least 41 percent, which is not negligible against a powerful House chairman who was leading the effort to get President Trump’s tax returns. (The Supreme Court halted Congress’s efforts.)

Massachusetts was the last big primary for Democrats in 2020. As the Democratic National Convention took pains to show, there is every reason to believe that a truce is coming now between the left and the center, aimed at defeating Trump and trying to retake the Senate, as well as make gains in House Democrats’ majority. It’s even possible that Democrats could control the White House and both chambers of Congress in January.

But as The Post’s Dan Balz has reported, there’s also every reason to think the party has a fragile truce between its wings. And liberals see their wins and even some of their losses this summer as all the more reason to keep pushing the party to the left.

“We really do care on being able to move the ball forward on major pieces of progressive legislation,” said Lucy Solomon of Indivisible. “And having the most progressive House possible in that trifecta will be key to advancing that progressive agenda.”

Which means that next election cycle, more House Democrats can expect to get a primary challenger who gives them the race of their life. And after supporting primary candidates of their own, the Democratic establishment has less leverage than ever to stop it.