As President Obama’s reelection campaign was ramping up five years ago, Sen. Bernie Sanders suggested on several occasions that it would be healthy if someone ran against him from the left — channeling the frustration of activists who thought the president had compromised on core liberal principles.

“If a progressive Democrat wants to run, I think it would enliven the debate, raise some issues, and people have a right to do that,” he told WNYC’s Brian Lehrer in March 2011.

The episode illustrates how Sanders’s rhetoric has adjusted to reflect his changed standing. Once an outside critic of the system, he is now running to inherit the Democratic Party that Obama has led for nearly two terms.

Yet Sanders’s brand of unflinching independence is central to his appeal for many voters. Those earlier criticisms of Obama elevated his stature on the political left, leading activists to push him to make his own presidential bid.

Sanders ultimately endorsed Obama despite his public musings. But former secretary of state Hillary Clinton has seized on his critique of the president in this year’s White House contest, casting the senator from Vermont as disloyal to Obama at a time when they are scrapping over supporters.

President Barack Obama, accompanied by Sen. Bernard Sanders and Vermont Gov. Peter Shumlin, greets supporters on the tarmac upon his arrival at Burlington Air National Guard Base, March, 30, 2012, in Burlington, Vt. (Pablo Martinez Monsivais/AP)

That notion drew a strong objection from Sanders during Sunday’s Democratic debate.

“In 2012, I worked as hard as I could to see that he was reelected,” the senator said, adding that he and the president are “friends.”

[Clinton and Sanders sharpen their tone as the stakes rise]

Nearing the end of Obama’s first term, the mood among the party’s liberal wing was restive. There was anger that Wall Street executives were flourishing during the country’s recession and angst that Obama’s signature health-care legislation did not go as far as many had hoped it would. Cuts to Medicare and Medicaid that the White House was considering as part of negotiations with congressional Republicans infuriated many in the base.

“There was a feeling that we were sold out on some very big things,” said Mike Lux, a political strategist for progressive organizations who has remained neutral in this year’s Democratic race. “I think Bernie just reflected what a lot of people were feeling.”

Sanders issued a strong public rebuke to Obama in December 2010, when he delivered an 8 1/ 2 -hour speech on the Senate floor, denouncing a tax-cut deal that the White House had struck with Republican leaders.

In the months that followed, his comments about Obama grew more pointed. In a July 2011 interview on Thom Hartmann’s radio program, Sanders said in response to a caller that “there are millions of Americans who are deeply disappointed in the president, who believe that, with regard to Social Security and a number of other issues, he said one thing as a candidate and is doing something very much else as a president, who cannot believe how weak he has been, for whatever reason, in negotiating with Republicans.”

1 of 42 Full Screen Autoplay Close Skip Ad × Highlights from Bernie Sanders’s campaign, in pictures View Photos The senator from Vermont has become Hillary Clinton’s chief rival in the contest for the Democratic nomination. Caption The senator from Vermont is Hillary Clinton’s rival in the contest for the Democratic presidential nomination. June 14, 2016 Bernie Sanders arrives at the Capital Hilton to meet with Hillary Clinton in D.C. Matt McClain/The Washington Post Buy Photo Wait 1 second to continue.

Later in the program, in response to a second caller, he said he was contemplating encouraging someone to run against Obama.

“There are a lot of smart, honest progressive people who I think can be good presidents,” he said. “And I think one of the reasons President Obama has moved as far to the right as he has, is he thinks he can go all the way and no one will stand up to him.”

The following month, in response to a question on C-SPAN about whether he had anyone in mind as a primary challenger, Sanders responded: “No, I don’t know of anybody in mind, but I’m sure there are serious, smart people out there who could do it.”

[Liberal activists see Bernie Sanders as champion for causes failed by Obama]

His remarks gave some on the left hope that Sanders himself would challenge Obama. The senator soon made it clear he was not interested.

Consumer activist Ralph Na­der, who was working at the time to try to identify a primary challenger to take on the president, said of Sanders: “He backed away right away, so there wasn’t anything to cling to.”

But Sanders’s statements brought him additional attention from liberals, particularly Progressive Democrats of America, a group formed in 2004 by activists who had worked on the presidential campaigns of former Vermont governor Howard Dean and former Ohio congressman Dennis Kucinich.

Tim Carpenter, then the group’s executive director, kept lobbying Sanders to consider a bid in 2016, according to Medea Benjamin, a peace activist who serves on the group’s advisory board.

“Tim and PDA were constantly pushing Bernie to run,” she said. “I remember it all very clearly, feeling his reluctance on the one hand but also a certain excitement on the other hand. I think he was always looking for someone else to do it, but the someone else wasn’t there.”

In the spring of 2014, Carpenter and PDA launched an online petition urging Sanders to make a White House run — specifically not as an independent, his mantle as a senator, but as a candidate for the Democratic nomination. He invited Sanders to deliver the keynote address at the group’s 10th-anniversary celebration in Northampton, Mass.

[Sanders prepares to challenge Clinton on Super Tuesday and beyond]

Carpenter died of cancer about two weeks before the gathering. But the group presented Sanders with the results of their petition drive: 11,000 signatures from people asking him to jump into the Democratic primary race.

Sanders did not offer any clues about his thinking. But in his speech to the group, he laid out his vision for the country, previewing many of the themes that now make up the core of his 2016 campaign.

He ticked off statistics to explain the building anger among the middle class as their median income had fallen, the increased number of families living in poverty and the concentration of the wealth in the hands of a few.

“No matter who the next president of the United States is — this I say with absolute certainty — if that president is serious about addressing the huge crisis facing this country,” he said, “that president cannot do it unless there is a political revolution.”

After speaking for an hour, Sanders shook hands with supporters as he walked down the aisle. The room echoed with chants of “Run, Bernie, run!”