WASHINGTON — President Obama angrily denounced Donald J. Trump on Tuesday for his remarks in the aftermath of the shooting massacre in Orlando, Fla., warning that Mr. Trump, the presumptive Republican presidential nominee, was peddling a “dangerous” mind-set that recalled the darkest and most shameful periods in American history.

“We hear language that singles out immigrants and suggests entire religious communities are complicit in violence,” Mr. Obama said at the Treasury Department, without mentioning Mr. Trump by name. His statement, an extraordinary condemnation by a sitting president of a man who is to be the opposing party’s nominee for the White House, came after Mr. Obama met with his national security team on the status of the American effort against the Islamic State, a meeting that the president said had been dominated by discussion of the Orlando rampage.

“Where does this stop?” Mr. Obama said of Mr. Trump’s approach, noting that Mr. Trump had proposed a ban on admitting Muslims into the United States, and that the Orlando assailant, like perpetrators of previous domestic terrorist attacks in San Bernardino, Calif., and Fort Hood, Tex., was an American citizen.

“Are we going to start treating all Muslim-Americans differently? Are we going to start subjecting them to special surveillance? Are we going to start discriminating against them because of their faith?” Mr. Obama asked, his voice rising with frustration. “Do Republican officials actually agree with this? Because that’s not the America we want — it doesn’t reflect our democratic ideals. It won’t make us more safe. It will make us less safe.”

Appearing in Pittsburgh as Mr. Obama spoke, Hillary Clinton gave a blistering denunciation of her own. She echoed many of the president’s points and even some of his language, assailing Mr. Trump’s temperament, ridiculing his proposals and arguing forcefully that he had failed to meet the gravity of the moment.

“History will remember what we do in this moment,” she told hundreds of supporters inside a union hall, asking “responsible Republican leaders” to join her in condemning Mr. Trump. “What Donald Trump is saying is shameful.”

Her half-hour speech was a point-by-point rebuttal to Mr. Trump’s remarks a day earlier, when he issued a searing broadside implying that all Muslim immigrants posed a threat to American security. The nearly simultaneous condemnations of Mr. Trump from the president and the presumptive Democratic nominee to succeed him had the feel of a coordinated assault, although the White House insisted there had been no preplanning.