MANCHESTER, N.H. — Bernie Sanders, Congress’s longest-serving independent and a self-described socialist, backtracked just two days into his presidential campaign Saturday, saying he would register as a Democrat if needed to compete in the party’s primary in all 50 states.

Announcing his candidacy Thursday outside the U.S. Capitol, the Vermont senator rejected any suggestion that he register as a Democrat. “No,” Sanders said, “I’m an independent.”

But a day later, questions surfaced in New Hampshire about whether he would be eligible to compete next year in the nation’s first presidential primary. New Hampshire requires candidates to fill out a form declaring party registration. Sanders also rejected the Democratic nomination for Senate twice in Vermont.

On Saturday, after addressing more than 100 supporters stuffed in a Manchester home and spilling out into a yard, Sanders said: “We will do what we have to do” to make sure his name appears on the ballot alongside Hillary Rodham Clinton.

Sanders’ new openness to registering as a Democrat follows his campaign’s statement that he raised an impressive $1.5 million in the first 24 hours of his announcing: a grass-roots surge from 35,000 donors who gave an average of $43.54 apiece, the campaign reported.

Sanders stressed repeatedly Saturday that he is in the race to win it. Known in Washington as a pragmatic politician, his party affiliation appeared to be an early compromise, though he often sits with the Democratic caucus.

“We’re going to fulfill all the rules,” Sanders said, when asked about the potential roadblock.

“You know, I am the longest-serving independent in congressional history. I made the decision that the best way to be effective in this campaign, the best way to win was to do it through the democratic primary process. We will meet all of the requirements of all of the states, including New Hampshire,” he said.

Even if that requires registering as a Democrat?

“We will do what we have to do. We are going to be on the ballot in 50 states. You don’t win unless you do that,” Sanders said.