What’s happening in Cairo and Benghazi appears to be a case of political opportunism — no, not by Mitt Romney, though there was some of that Wednesday — but by Salafist Islamic extremists who are unhappy with the success that more moderate Islamist and secularist parties in Egypt and Libya have had in building political support.

We’re still in what I like to call the “fog of revolution” in both countries, where it’s hard to know for sure what’s happening and who benefits, so my reporting comes with a basic caveat. But based on conversations with sources who were on the streets Tuesday in the midst of the Cairo demonstration and who have been following events in Libya closely, it’s possible to pierce the fog a bit and offer some basic analysis:

First, the situation in Cairo: The Arabic banners of the protesters moving toward the U.S. Embassy identified them as members of the Nour Partyand the al-Asala Party, the two leading Salafist groups that have competed in the Egyptian elections. The Salafists, whose name connotes respect for the Islamic “ancestors” of the prophet Mohammed’s time, are more conservative and less pragmatic than the Muslim Brotherhood, now ruling Egypt.

An analyst who was in the midst of that crowd Tuesday told me that he thinks the Salafist demonstrators were using the pretext of a supposedly anti-Islamic American film to send two messages: The first was obviously anti-Americanism, which is potent in today’s Egypt; the second and more interesting message was a challenge by the Salafists to their rivals in the Muslim Brotherhood government of President Mohamed Morsi.

As is so often the case in revolutions, the Cairo uproar appears to be partly a case of radicals wanting to undermine a more moderate governing party. The Salafist demonstrators’ threat was augmented by violent hooligans, who are often described as soccer fans but increasingly are inflammatory anarchists.

A similar process of post-revolutionary jockeying is going on in Libya, and it tragically led to the death Tuesday of Ambassador Christopher J. Stevens and three other Americans. The Salafists’ assault on the U.S. consulate in Benghazi at first appeared to be a “copycat” attack like the one in Cairo, but U.S. officials said it may have been planned by extremists linked to al-Qaeda. They were augmented by a well-armed Islamic militia. Their anger, again, is mixed between a baseline anti-Americanism (sadly, always a draw in the region) and a challenge to Prime Minister Abdurraheem el-Keib and the secularist parties that are the backbone of the new Libyan government.

Does America have an interest in the internal fights taking place in these countries still quaking from the Arab uprisings? Of course it does, especially when U.S. embassies are targets of protesters and U.S. diplomats get killed in the crossfire. But this isn’t really about America: It’s about factions battling for power in a fluid political situation.

Unfortunately, the seizure of the U.S. Embassy in Tehran in 1979 is an apt parallel. That was the work of a group of extremist Iranian “students” who were unhappy that the post-revolutionary government of Ayatollah Khomeini wasn’t proving radical enough. They captured the revolution when they seized the embassy. The lesson of that disaster is that local security authorities must quickly restore order — and if they can’t or won’t, then Americans must move out of harm’s way.

Also worrisome is the link between Salafists (whose posters worryingly appear in Cairo neighborhoods near Heliopolis that are populated by members of the military) and the more violent “takfiri” wing, which believes it’s permissible to kill apostate Muslims and has links with al-Qaeda. The takfiris hate the ruling Muslim Brotherhood, if that’s any consolation.

The delicate political balance in Egypt and Libya makes the blunderbuss campaign rhetoric of Romney, the Republican presidential candidate, especially unfortunate. His comments make this crisis more “about America” than it needs to be.

Let’s return to the main trigger for these events: It’s the success of the tolerably non-extremist (I won’t say “moderate”) governments in Egypt and Libya in consolidating power, and the anger of the more radical Salafists at this success. Morsi, for example, has just won pledges of billions in financial support from Saudi Arabia and Qatar. The Gulf Arabs are making a bet that over the next year, Morsi can stabilize Egypt and get the economy moving again. Despite Tuesday’s tragic events, the United States should make the same bet.