President Obama at the Islamic Society of Baltimore, in Windsor Mill, Md., on Wednesday. (Mandel Ngan/Agence France-Presse via Getty Images)

WHEN PRESIDENT Obama visited a synagogue in Washington last May, his second time at a Jewish house of worship in this country as chief executive, there wasn’t a peep from the Republican candidates seeking their party’s presidential nomination. Yet when Mr. Obama turned up at the Islamic Society of Baltimore on Wednesday, his first visit to an American mosque after seven years in office, Republican presidential hopefuls Donald Trump and Sen. Marco Rubio (Fla.) let loose a toxic barrage of snark and sanctimony.

The president’s message at the suburban Baltimore mosque was patriotic, inclusive, tolerant and empathetic — it was, in short, presidential. Mindful of FBI statistics and reports of rising vandalism, threats and other hate crimes against American Muslims and mosques — including the mosque in Baltimore he visited — Mr. Obama delivered a timely reminder that Muslims belong in the United States and are as fully American as Christians, Jews and any other citizens. In that sense his remarks were, almost literally, all-American.

It’s fair to say the president waited too long to visit an American mosque, though he’s been to ones overseas. Hate crimes against American Muslims and places of worship have quintupled since Sept. 11, 2001, and they jumped again in 2014 even as such crimes declined against other groups, according to the FBI. (In raw numbers, there are still more hate crimes directed at Jews than Muslims in the United States.)

Since the terrorist attacks in Paris in November and in San Bernardino, Calif., the following month, there has been a new spike in hate crimes against Muslims and mosques, including vandalism, graffiti, verbal threats and assaults. They are a gift to the Islamic State and encouraged, intentionally or not, by Mr. Trump, Mr. Rubio, Sen. Ted Cruz (Tex.), Ben Carson and other GOP luminaries, who have cynically taken the terrorists’ carnage as opportunities to whip up xenophobic fear and venom.

So Mr. Obama’s visit, even if overdue, was timely. It was a refutation of the hate-baiting on the Republican stump — calls to exclude Muslim immigrants (Trump, et al.), disqualify American Muslim presidential candidates (Carson) and conflate anti-Muslim hate speech with efforts to combat terrorism (Cruz). His speech was a reminder of what makes Americans American — not citizens’ place of worship but rather their allegiance to certain principles, including tolerance.

To that positive and patriotic message, Mr. Trump responded with his trademark sneer and umpteenth intimation that Mr. Obama, a Christian, is a closet Muslim. “I don’t have much thought,” Mr. Trump said, accurately. “Maybe he feels comfortable there. . . . There are a lot of places he can go, and he chose a mosque.”

Mr. Rubio somehow contorted the president’s message of inclusiveness into “pitting people against each other.” This, the Floridian said piously, “is hurting our country badly.”

What’s hurting the country badly are hate-mongers who would rather betray American values by appealing to bigotry than address the reality of 2 million to 3 million American Muslims, the overwhelming majority of them patriotic, who are as entitled to dignity and respect as everyone else.