WASHINGTON — President Obama on Wednesday called for Americans to reject “bigotry in all its forms” and keep pressing for equality “no matter what ugliness might bubble up,” appearing to use the 150th anniversary of the constitutional amendment abolishing slavery to challenge the incendiary anti-Muslim politics espoused by Donald J. Trump.

At a ceremony at the Capitol attended by congressional leaders and civil rights activists, Mr. Obama sought to place the end of slavery in the broader context of the nation’s troubled history, saying the issue “was never simply about civil rights; it was about the meaning of America, the kind of country we wanted to be.”

But he also made subtle reference to the roiling political debate that is consuming the 2016 presidential race, implicitly rebuking Mr. Trump, the Republican front-runner in the polls, who has proposed temporarily barring foreign Muslims from entering the United States.

“Our freedom is bound up with the freedom of others, regardless of what they look like, or where they come from, or what their last name is or what faith they practice,” Mr. Obama said in the Capitol Visitor Center’s Emancipation Hall, filled with statues and busts of human rights leaders including Sojourner Truth.

His voice rose considerably as he mentioned “faith,” and many attendees, including Representative Nancy Pelosi of California, the House minority leader, gave him a standing ovation at the reference. Senator Harry Reid of Nevada, the Democratic leader, however, remained seated, along with Speaker Paul D. Ryan of Wisconsin and Senator Mitch McConnell of Kentucky, the majority leader.

“We betray the efforts of the past if we fail to push back against bigotry in all its forms,” Mr. Obama said. “We betray our most noble past as well if we were to deny the possibility of movement, the possibility of progress — if we were to let cynicism consume us and fear overwhelm us, if we lost hope.”

The president did not mention Mr. Trump in his remarks. The White House said Mr. Obama had not intended to speak directly to Mr. Trump in his speech, nor had any language been “newly inserted” to respond to one individual.

“This is quite consistent with the message the president has been delivering for a number of years,” said Josh Earnest, the White House press secretary, when asked about the comments during a briefing with reporters. “It stands in quite stark contrast to the language, message and values that is being promulgated not only by Mr. Trump, but by a variety of Republican candidates in the presidential field.”

The ceremony drew congressional leaders from both parties, as well as a group of black lawmakers who took turns recounting the process by which the 13th Amendment was passed in Congress and then ratified by the states, reaching the requisite three-fourths of the states on Dec. 6, 1865, when Georgia ratified it.

“At long last, we stopped poisoning the soul of our country with the atrocity of slavery,” Ms. Pelosi said.

Mr. Ryan noted that black soldiers fought in segregated forces during the Civil War and said the simple wording of the 43-word amendment belied its significance. “We have witnessed true greatness in this country,” he said. “And when we ratified the 13th Amendment, we committed ourselves to building a country just as great.”

In his remarks, Mr. Obama returned to themes he has sounded throughout his presidency — but with increasing frequency during his second term — acknowledging the painful legacy and lingering scars of slavery and racial discrimination, as well as the potential for moving beyond them that he has come to embody as the nation’s first black president.

“That’s what we celebrate today, the long arc of progress,” Mr. Obama said. “Progress that is never assured, never guaranteed, but always possible, always there to be earned, no matter how stuck we might seem sometimes, however divided or despairing we might appear, no matter what ugliness might bubble up.”

He said Americans would “do a disservice” to those who fought for an end to slavery “were we to deny that the scars of our nation’s original sin are still with us today.”