As summer turned to fall in late September, Sen. Bernie Sanders was working hard to clinch coveted endorsements from two of the country’s most prominent liberal icons: Reps. Ilhan Omar and Alexandria Ocasio-Cortez.

At the time, many Democrats were unsure whether they would back Sanders or his liberal rival Sen. Elizabeth Warren (D-Mass.), but behind the scenes, Sanders (I-Vt.) was closing in. On Sept. 21, Omar (D-Minn.) spoke at an Iowa forum where she outlined the need for a candidate who would fight for broad change, and soon after, she advocated for Sanders with other members of “the Squad,” a group of left-leaning female House members, according to an aide who is close to her.

A week later, Ocasio-Cortez (D-N.Y.), also a Squad member, visited Sanders in his hometown of Burlington, Vt., and the two sat down for breakfast, joined by Sanders’s wife, Jane, and his campaign manager, Faiz Shakir. Ocasio-Cortez’s visit “was a very key step in the process” of earning her endorsement, Shakir said later.

The maneuvering paid off in a big way this week, when Sanders scored one of the biggest coups of the primary season, as Omar announced late Tuesday she was endorsing him and Ocasio-Cortez plans to do the same on Saturday.

A third member of the Squad, Rep. Rashida Tlaib (D-Mich.), has opened the door to endorsing Sanders. Sanders’s campaign announced Wednesday that he will join Tlaib for a tour of her Detroit district later this month.

Two weeks ago, Sanders, 78, had a heart attack that raised questions about his health, drew attention to his age and prompted doubts about the viability of his campaign.

The endorsements suggest that despite Warren’s recent rise, the fight for the allegiance of the party’s liberal wing is far from over, and that Sanders still commands the loyalty of many Democrats who want the party to move sharply to the left.

The three lawmakers in many ways symbolize the youth, vitality and diversity of a new generation of Democrats. Although some in the party privately question whether the endorsements will win over many voters not already committed to Sanders, they have the potential to help him move past the most difficult chapter of his campaign, marked by falling polls as well as the heart attack.

“This isn’t just about the horse race — it also helps Team Bernie turn the page from last week and start looking forward,” said Democratic strategist Rebecca Katz. “ ‘Bernie is back’ is a real thing.”

Katz was referring to the catchphrase the Sanders campaign is using to brand his return to the campaign trail after his hospitalization. After a well-received debate performance Tuesday night, Sanders plans to hold his first rally since his health scare on Saturday in Queens, N.Y., where Ocasio-Cortez will join him.

Aides have eagerly been promoting the event and Sanders teased the rally at the debate, saying he would have a “special guest” though not identifying the person. With a large online following and high name recognition, Ocasio-Cortez could energize the rally and become a significant asset for the Sanders campaign in her home state and potentially beyond.

Few figures hold as much sway with the party’s liberal wing as Ocasio-Cortez, who at age 30 represents a new generation of young left-leaning activists who are pushing such ideas as the Green New Deal and show an easy deftness with social media.

Omar, 38, like Ocasio-Cortez is part of the wave of Democrats, many of them women, who swept into the House in 2018 powered by a backlash against President Trump. The two lawmakers also reflect the growing diversity of the Democratic Party. Omar, a Somali American, is the first woman in Congress to wear a hijab, a Muslim head covering, while Ocasio-Cortez is of Puerto Rican descent.

In some ways, endorsing Sanders was a natural choice for Ocasio-Cortez. She worked as a volunteer for Sanders’s 2016 presidential bid and, like the senator, identifies as a democratic socialist. On health care, climate change and a federal jobs guarantee, the two are closely aligned.

But the emergence of Warren as a liberal alternative to Sanders, who has been outperforming him in the polls and would make history as the first female president, created uncertainty about what Ocasio-Cortez would do. Both Sanders and Warren aggressively courted Ocasio-Cortez, collaborating on legislation with the congresswoman, dining with her and showing support for her on social media.

Yet it was Sanders who prevailed in the endorsement chase, with an approach that mirrored his strategy for winning voters: methodical, policy-driven and consistent.

“A lot of good conversations. A lot of good, thoughtful conversations,” Shakir said after Tuesday’s debate, explaining the process that won her over.

He said the endorsements were part of a larger plan heading into the final months before the first nominating contest, the Feb. 3 Iowa caucuses. “We thought it would be very helpful to start rolling these out in October and keep building momentum into November and December and ultimately, hopefully, win the Iowa caucuses,” said Shakir.

Rep. Ro Khanna (D-Calif.), a Sanders campaign co-chair, said the biggest benefit of the endorsements “is the message that Bernie Sanders resonates with young people, with communities of color, with women.” Sanders has sometimes struggled to attract African American audiences.

Campaign officials hope the endorsements will lead to more support. In an email to top campaign personnel Wednesday, Sanders’s political team said it was eager to roll out a new slate of state-level endorsements, but was holding off until next week to allow for more time to woo people who may have been swayed by the debate and the congressional endorsements.

It was after Sanders had his heart attack that Omar privately told him she would support him, according to the aide close to her, though she had long been moving in that direction. The campaign announced the endorsement Tuesday night after The Washington Post reported Ocasio-Cortez’s forthcoming support.

On Wednesday, the Sanders campaign released a video featuring Omar.

“The senator is the only candidate that isn’t about leaning a particular way, but being true to yourself and fighting for what you believe regardless of what the obstacles are,” Omar says in the video. In her Iowa speech, the ideal president she described closely resembled Sanders.

Omar was swayed by Sanders primarily because of his policy positions, said her aide, who spoke on the condition of anonymity to be candid. The two teamed up on a bill to curb student debt earlier this year, and this week they introduced a joint legislative proposal for a universal school meals program.

The one member of the Squad who has not signaled at least the possibility of endorsing Sanders is Rep. Ayanna Pressley (D-Mass.), who represents a district in Warren’s home state and is publicly neutral. A spokesperson for Pressley distanced her from the decisions of other congresswomen Wednesday.

“Ayanna has tremendous respect for her sisters-in-service. Ultimately, these political decisions are made as individuals,” the spokesperson said in a statement. “Ayanna knows that taking back the White House in 2020 is a top priority, and she is working every day to hold this administration accountable and build a bold, diverse movement that will help propel Democrats to victory up and down the ballot.”

Support from members of the Squad is not risk-free and could alienate more moderate Democrats. At times, the lawmakers have stoked controversy within their party’s ranks.

In February, for example, Omar faced a forceful rebuke from Democratic leaders for suggesting that Israel’s allies in American politics were motivated by money rather than principle. She apologized for her comments.

Trump has also attacked the members of the Squad, at one point suggesting they should “go back” to their own countries — even though they are American citizens — and has sought to make them the face of the Democratic Party. He recently held a rally in Omar’s district.

But Sanders campaign officials said that trying to design an approach in anticipation of what critics will say is a faulty strategy. The best bet, they said, is to lean into your core beliefs.

“Look, the haters are gonna hate regardless,” said Nina Turner, a national co-chair of the Sanders campaign. “So why not just ride this thing on out and do it in a way where the senator has the ability to do the greatest amount of good?”

It remains unclear whether Sanders’s campaign can fully rebound following the candidate’s heart attack, which required not only a hospital stay but also the insertion of two stents in an artery and drew renewed attention to his age. But for Sanders, the past 48 hours have been some of the most productive of the race.

He raised more than $620,000 from 40,000-plus contributions Tuesday, his campaign said.

Thirty-five percent of all money raised on ActBlue — the main online clearinghouse Democrats use to raise money — between the hours of 9 and 10 p.m. Eastern time went to Sanders, the campaign said, even though there are 18 Democrats in the race and 12 appeared on the debate stage.

But sustaining momentum has been a challenge. After an impressive start, Sanders stagnated over the summer and struggled to keep up with Warren and Biden in the polls. Campaign officials are hoping things will turn out differently this time, particularly as the year’s end is rapidly approaching and candidates do not have unlimited time to mount a surge.

“This is the moment, in our perspective, that everything has to move in the upward direction,” Shakir said. “It was our view that we wanted to start off the fourth quarter with some strength. I think rolling out a couple major endorsements of people who can inspire a lot of young people around this country is a good marker, I hope, of success in the next months to come.”

Janes reported from Westerville, Ohio. David Weigel contributed to this report.