On Wednesday, Mr. Obama, who is campaigning, called staff members at the White House from Air Force One to arrange a telephone call to Mr. Morsi, a senior administration official said.

The president was not happy; Egypt, unlike Libya, is crucial to American security interests, given its peace treaty with Israel. At 11 p.m., from his hotel suite in Denver, Colo., Mr. Obama got on the phone with Mr. Morsi, who began by offering condolences on the American deaths in Libya.

But that was not what Mr. Obama was calling about.

“The president made his point that we’ve been committed to the process of change in Egypt, and we want to continue to build a relationship with the Egyptian government,” said a senior administration official. “But he made it clear how important it is that the Egyptian government work with us to lower the tension both in terms of the practical cooperation they give us and the statements they make.”

Mr. Morsi brought up the American-made video attacking the Prophet Muhammad, which had set off the violent protests, and Mr. Obama said he understood the ire felt by Muslims, but added that it did not justify attacks on the embassy.

Mr. Obama urged Mr. Morsi to publicly and strongly condemn the attacks. He had already signaled his displeasure earlier, saying in an interview on Telemundo that Egypt was not necessarily an “ally,” although White House officials were playing down the remark on Thursday.

“ ‘Ally’ is a legal term of art,” said Tommy Vietor, a spokesman with the National Security Council. “We don’t have a mutual defense treaty with Egypt like we do with our NATO allies.”