Sen. Bernie Sanders (I-Vt.), a Democratic presidential candidate, speaks during the Iowa Democratic Party Hall of Fame Celebration dinner in Cedar Rapids in July. (Daniel Acker/Bloomberg News)

PORTSMOUTH, N.H. — Democratic presidential hopeful Bernie Sanders on Sunday denounced the assertion by Republican candidate Ben Carson that he would not support a Muslim for president, saying Carson’s comments reflected antiquated thinking.

“You know, this is the year 2015,” Sanders told reporters following the opening of a new campaign office here. “You judge candidates for president not on their religion, not on the color of their skin, but on their ideas on what they stand for. … I was very disappointed in Dr. Carson’s statement.”

During an interview that aired Sunday morning on NBC’s “Meet the Press,” Carson, a retired neurosurgeon who has risen rapidly in the Republican field, said, “I would not advocate that we put a Muslim in charge of this nation. I absolutely would not agree with that.”

[Ben Carson says he would not support a Muslim for president]

Carson said earlier in the discussion that a president’s faith should not matter so long as it’s “within the realm of America and consistent with the Constitution, no problem.”

When host Chuck Todd pressed him on whether he believes “Islam is consistent with the Constitution,” Carson said, “No, I don't. I do not.”

Sanders, an independent senator from Vermont who has emerged as a threat to Hillary Rodham Clinton in the Democratic nominating contest, compared Carson’s comments to earlier eras when Americans would not embrace Catholics or African Americans as president.

“For a long, long time in the history of America, there were people saying, 'Oh, we don’t want a Catholic to be president of the United States,' ” Sanders said. “Then John F. Kennedy became president in 1960. And then people said, 'Oh, we don’t want a black guy, an African American, to be president of the United States.' Then finally Barack Obama became president of the United States.”

[What Bernie Sanders means by ‘democratic socialism.’]

Throughout the campaign, Sanders has been loath to criticize his Democratic rivals. But he has been less reserved when it comes to taking aim at Republicans, including the party's front-runner, Donald Trump, whose comments about Mexicans Sanders has called racist.

Sanders was in the middle of a two-day campaign visit to New Hampshire, where recent polls have showed him leading Clinton. He is scheduled to wrap up his trip with a rally Sunday night at the University of New Hampshire in Durham.

Jose A. DelReal contributed to this report.