“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.

Video

Trump and Clinton on Orlando Shooting

Hillary Clinton’s and Donald J. Trump’s responses to the massacre in Orlando, Fla., highlighted their differences on gun control and immigration.

By EDWARD FETNER and DAVE HORN on Publish Date June 13, 2016.Photo by Damon Winter/The New York Times.Watch in Times Video »

Mr. Trump, unbowed by the criticism, said Mr. Obama was coddling terrorists.

“President Obama claims to know our enemy, and yet he continues to prioritize our enemy over our allies and, for that matter, the American people,” he said in a statement on Tuesday. “When I am president, it will always be America first.”

Members of Mr. Trump’s party were themselves critical of his rhetoric and proposals. Speaker Paul D. Ryan, the nation’s highest-ranking elected Republican, said at a news conference Tuesday that Mr. Trump’s proposed ban on Muslim immigrants was not in the country’s interests, nor did it reflect the principles of his party.

“There’s a really important distinction that every American needs to keep in mind: This is a war with radical Islam. It’s not a war with Islam,” Mr. Ryan said. “The vast, vast majority of Muslims in this country and around the world are moderate, they’re peaceful, they’re tolerant, and so they’re among our best allies, among our best resources in this fight against radical Islamic terrorism.”

Senator Jeff Flake, the Arizona Republican who has been among the most outspoken in his party about withholding his endorsement of Mr. Trump, said in a Twitter post that he was “appreciative” that Mr. Ryan had spoken out.

Senator Mitch McConnell of Kentucky, the majority leader, flatly refused to talk about his party’s presidential nominee on Tuesday, an indication of the precarious position in which Mr. Trump has placed Republican elected officials.

Mr. Obama bitterly rejected criticism from Mr. Trump and other Republicans about his steadfast refusal to use the term “radical Islam” to describe the Islamic State, which is also known as ISIS or ISIL.

“If there’s anyone out there who thinks we’re confused about who our enemies are, that would come as a surprise to the thousands of terrorists who we’ve taken off the battlefield,” Mr. Obama said at the Treasury. “There’s no magic to the phrase ‘radical Islam.’ It’s a political talking point. It’s not a strategy.”

Mrs. Clinton echoed the idea, asking pointedly in her speech: “Is Donald Trump suggesting that there are magic words that once uttered will stop terrorists from coming after us?”

OPEN Graphic

Graphic: What Happened Inside the Orlando Nightclub

The president said he would not use the wording because he was unwilling to give the Islamic State the victory of acceptance of its vision that it is the leader of a holy war between Islam and the West.

“If we fall into the trap of painting all Muslims with a broad brush and imply that we are at war with an entire religion, then we are doing the terrorists’ work for them,” Mr. Obama said.

Mr. Obama is scheduled to travel to Orlando on Thursday to visit with the surviving victims and the families of those killed in the rampage on Sunday morning. He was to have traveled to Wisconsin on Wednesday for his first campaign appearance with Mrs. Clinton since endorsing her last week, but the event was canceled in light of the shooting.

Still, Tuesday’s one-two punch left little doubt that Mr. Obama and Mrs. Clinton plan to savage Mr. Trump on the campaign trail. The president was careful not to cast his criticism in political terms and never mentioned Mr. Trump’s name even as he clearly targeted him — at one point referring derisively to “politicians who tweet” — and his policy proposals. Instead, Mr. Obama spoke ominously of the stakes for the nation’s security, and its very identity, if the ideas that Mr. Trump has espoused are widely accepted.

“We’ve gone through moments in our history before where we acted out of fear, and we came to regret it,” Mr. Obama said. “We’ve seen our government mistreat our fellow citizens, and it as been a shameful part of our history.”

Mrs. Clinton, in a striking departure from her speech on Monday, when she refrained from saying Mr. Trump’s name and said it was “not a day for politics,” took direct aim on Tuesday at his penchant for conspiracy theory. She reminded the crowd that he was “a leader of the birther movement” questioning Mr. Obama’s birthplace.

After the Orlando attack, she noted, Mr. Trump suggested on television that Mr. Obama sympathized with Islamic terrorists.

“Just think about that for a second,” Mrs. Clinton said. “Even in a time of divided politics, this is way beyond anything that should be said by someone running for president of the United States.”

Photo

Hillary Clinton, the presumed Democratic nominee for president, echoed many of President Obama’s points in a speech on Tuesday in Pittsburgh.Credit Eric Thayer for The New York Times

Mr. Obama staunchly defended his administration’s approach to countering terrorism, listing gains that the United States has made against the Islamic State in Iraq, Syria and Libya: killing the group’s top leaders, capturing more of its territory and whittling away at its financial resources.

He also called on Congress to enact gun restrictions that it has so far resisted, including the resurrection of a ban on assault weapons and a measure that would bar people on “no-fly” lists because of suspected terrorist ties from buying a gun.

“Enough talking about being tough on terrorism,” Mr. Obama said. “Actually be tough on terrorism and stop making it as easy as possible for terrorists to buy assault weapons.”

The last time a president so aggressively injected himself into the race to succeed him was in 2000. But Bill Clinton’s criticism of George W. Bush, the governor of Texas and the Republican nominee that year, illustrates just how jarringly different this race is from a normal White House campaign.

“How bad can I be?” Mr. Clinton said at a fund-raiser that summer, mimicking the voice of Mr. Bush. “I’ve been governor of Texas. My daddy was president. I own a baseball team. They like me down there.”

”Everything is rocking along hunky-dory,” he added. “Their fraternity had it for eight years, give it to ours for eight years.”

The ridicule, while tame by today’s standards, infuriated Mr. Bush’s father, former President George Bush, who warned that if Mr. Clinton “continues that, then I’m going to tell the nation what I think about him as a human being and a person.’’