Yikes! It seems “The Daily Show” and diplomacy don’t mix.

That’s the lesson the U.S. Embassy in Cairo is learning the hard way after being rebuked by both the Egyptian government and the State Department for causing an international incident. The embassy tweeted a link to a Jon Stewart monologue that mocked Egypt’s president — offending the Egyptians — and then deleted its entire Twitter account before restoring it without the post in question, irritating Washington.

Egyptian President Mohammed Morsi’s office called the tweet “inappropriate” and unbecoming of a diplomatic mission while the State Department said the unusual affair was the result of “glitches” in the embassy’s social media policies that are now being corrected.

The imbroglio over the tweet comes at a time of rising tensions between Cairo and Washington, which has expressed deep concerns that Morsi’s government is backsliding on human rights protections.

And, it underscores the pitfalls of allowing individual American embassies to control the messages they disseminate through social media.

The trouble began Tuesday when the embassy posted a link to Stewart’s monologue on his Comedy Central show the night before. Stewart took savage aim at Morsi for the arrest and interrogation of Egyptian comic Bassam Youssef, who has frequently criticized the president on a popular TV program that has been likened to Stewart’s own.

In the clip, Stewart accused Morsi of being petty, undemocratic and ignoring more pressing problems like Egypt’s economic crisis and violent crime to go after satirists who are critical of his government. He pointed out that he has made a living by poking fun at political leaders and that such activity is harmless and should be protected.

Morsi’s office responded to the embassy’s post on its own Twitter feed, saying: “It’s inappropriate for a diplomatic mission to engage in such negative political propaganda.”

The embassy responded Wednesday by deleting its entire Twitter account, drawing the wrath of State Department headquarters in Washington, which was already peeved by the initial post. The account was then restored minus the Stewart tweet.

“Embassies and consulates and their senior leadership manage the content that is on their feeds and they are expected to use good policy judgment in doing that,” State Department spokeswoman Victoria Nuland said.

On Monday, Nuland had made comments similar to Stewart’s, although more nuanced and couched in diplomatic terms, about Youssef’s arrest.

She declined to say whether the State Department agreed with the Egyptian government’s criticism of the tweet. But she suggested the embassy had erred by posting a link to a video that is already widely available on the Internet.

“I can’t speak to the decision to retweet Jon Stewart to start with,” she said. “But Jon Stewart is a comedy show in the U.S., as you know. It is publicly available content.”

She said the “glitches” she referred to were “the fact that they obviously put up something that they later took down, that they took down the whole site, which should not probably have been the way that went, and that in the past there have been differences between the Twitter team and senior post management.”

Steve Albani, spokesman for Comedy Central, declined to comment on the flap.

Nuland stressed that the U.S. position on the arrest of Youssef, whom she described as Egypt’s “Jon Stewart counterpart,” remained unchanged since Monday when she referred to it as part of a “”disturbing trend” of growing restrictions on freedom of expression in Egypt.