WASHINGTON — Since his 11-day tenure as the White House communications director ended in 2017 after an infamously foul-mouthed interview, Anthony Scaramucci has spent the past two years carving out a reliable niche for himself: defending President Trump on television networks like CNN and MSNBC where he has few on-camera allies.

But Mr. Trump’s trip last week to meet with the victims of two mass shootings in El Paso and Dayton, Ohio — a visit punctuated by private anger at his aides over negative news media coverage and public attacks on his political adversaries — appeared to be a bridge too far for Mr. Scaramucci.

“He’s off the rails,” Mr. Scaramucci said in an interview on Monday. “And the honest people in the room know that he is crazy.”

Mr. Scaramucci, a Republican investor who so shares Mr. Trump’s love of media attention that White House aides used to call him the president’s Mini-Me, has spent several days defecting from his reliably pro-Trump stance. He has sided with a chorus of critics who said the president’s behavior on last week’s trip, as well as his recent comments on race, was damaging for the country.