Editor's note: Are you in Egypt? Send us your experiences, but please stay safe.

Washington (CNN) -- President Barack Obama expressed deep concern on Wednesday about the Egyptian military's removal of that nation's first democratically elected president, calling for a quick return to civilian leadership and ordering a review of U.S. law regarding aid to the vital Middle East ally.

"The United States continues to believe firmly that the best foundation for lasting stability in Egypt is a democratic political order with participation from all sides and all political parties," Obama said in a statement about the move to oust Mohamed Morsy a year after he took office.

Obama said the United States expects the military to "ensure the rights" of Egyptian citizens "during this uncertain period."

He also called on the military to avoid "arbitrary arrests" of Morsy and his supporters. But Morsy and most members of his leadership team were under house arrest, according to the Muslim Brotherhood.

Obama's written statement followed a meeting of national security officials, including Defense Secretary Chuck Hagel, Joint Chiefs Chairman Gen. Martin Dempsey and CIA Director John Brennan at the White House, and illustrated a complex diplomatic situation.

The run-up to Morsy's removal included huge demonstrations on both sides of the political equation, with millions of people flooding Cairo squares in scenes similar to the mass protests and unrest that led to the military coup that toppled longtime leader Hosni Mubarak in 2011.

Obama refused to choose sides then and his administration adopted a similarly neutral stance ahead of the military's decision on Wednesday to suspend the constitution and remove Morsy, who left the Muslim Brotherhood after his election in a symbolic gesture as leader of all Egyptians.

The head of Egypt's Supreme Constitutional Court will serve as interim president.

The Obama administration said earlier in the day Egyptians deserved a "peaceful political solution."

But State Department spokeswoman Jen Psaki also noted that Morsy had failed to outline "significant specific steps" to address the concerns of anti-government protesters.

Tricky policy scenario for U.S.

The situation in Cairo created an uncomfortable policy scenario for a U.S. government and president that champion democratic principles.

Obama reinforced that in his statement.

"I now call on the Egyptian military to move quickly and responsibly to return full authority back to a democratically elected civilian government as soon as possible through an inclusive and transparent process," he said.

"The goal of any political process should be a government that respects the rights of all people, majority and minority; that institutionalizes the checks and balances upon which democracy depends; and that places the interests of the people above party or faction," he added, noting that those protesting Morsy's government must be heard.

But he also raised the tricky issue of military aid to Egypt, which also was noted by members of Congress in their reaction to events.

Egypt unrest: 5 key questions

Egypt's 1973 peace treaty with Israel and responsibility for keeping open the vital oil shipping lane of the Suez Canal make it an important player in the region regarding U.S. interests.

Democratic Sen. Pat Leahy of Vermont noted that the more than $1 billion a year in military aid to Egypt would be cut off if Morsy's overthrow is deemed a military coup.

U.S. law restricts some kinds of aid to countries where the elected head of government is deposed by a military coup, or a coup in which the military plays a decisive role.

Obama, who did not use the word "coup" in his statement, directed "relevant departments and agencies" to review the implications for aid to Egypt.

Rand Paul: Stop using U.S. taxpayer money to aid Morsy

Dempsey told CNN before Wednesday's announcement in Egypt that "there will be consequences" if the situation was "badly handled."

"If this were to be seen as a coup, then it would limit our ability to have the kind of relationship we need with the Egyptian armed forces," Dempsey said.

In a separate interview with CNN, former State Department official Edward Djerejian noted that the military's announcement included non-military figures from civil society to portray it as a broader political step than a military coup.

"There's something different happening here," said Djerejian, a former assistant secretary of state for Near Eastern affairs. He said the situation "creates the possibility for a political transition in Egypt to a pluralistic government system."

Initial statements from congressional Republicans who usually seize on any opportunity to criticize Obama policies were cautiously supportive of Morsy's ouster.

"I am hopeful that his departure will reopen the path to a better future for Egypt, and I encourage the military and all political parties to cooperate in the peaceful establishment of democratic institutions and new elections that lead to an Egypt where minority rights are protected," said a statement by GOP Rep. Ed Royce of California, who chairs the House Foreign Affairs Committee. "But make no mistake about it, Egypt is in for very difficult days."

A vital U.S. ally

Unrest in Egypt erupted as part of the Arab Spring wave of uprisings that began in North Africa in 2010.

The situation in Egypt has been a political thorn for Obama, forcing him to balance the interests of Israel with a U.S. desire to promote democratic values in the mostly Islamic region.

Opinion: Obama missed out on Arab Spring

Before Morsy's election, Obama announced efforts to help Egypt stabilize and modernize its economy, including debt relief of up to $1 billion and another $1 billion in loan guarantees.

Morsy's ascendency benefited Obama a few months later, when Morsy played a key role in negotiating a cease-fire between Hamas and Israel following eight days of Gaza violence last November.

But Morsy subsequently issued an order preventing any Egyptian court from overturning his decisions in what was considered an undemocratic move decried by opposition groups.

Within a month, he reinstated the judicial oversight and submitted a draft Islamist-backed constitution that voters approved and he signed into law.

What is the Muslim Brotherhood?

Public anger over economic woes and a lack of opposition voices in government helped spark the latest protests.

Mohamed Morsy: Fast Facts

Obama had called Morsy

The White House said on Tuesday that Obama had called Morsy to urge him to show Egyptians that he understood their anger and to take political steps to resolve the crisis.

The focus and tone of the White House statement was similar to a year ago when Morsy won Egypt's first election following Mubarak's ouster.

"We will stand with the Egyptian people as they pursue their aspirations for democracy, dignity, and opportunity, and fulfill the promise of their revolution," the White House said then.

Such a neutral approach has riled conservatives seeking a more assertive U.S. role in the aftermath of the Arab Spring uprisings that swept through parts of North Africa and the Middle East in recent years.

Republican Sen. John McCain of Arizona has criticized the president for yielding a leadership role in the region.

Shrinking U.S. aid

Last month, he warned a shrinking U.S. foreign aid budget meant "Egypt must show that it is a good investment of our scarce resources -- that the return on this investment will be a freer, more democratic, more tolerant Egypt."

If not, McCain said in a speech on the Middle East, "Congress will spend this money elsewhere. That is just a fact."

The Egyptian military this week gave Morsy an ultimatum to work out a solution to the protests by Wednesday. Morsy responded by calling for creation of a temporary coalition government until early elections can take place in coming months.

The statement posted Wednesday on Morsy's official Facebook page warned that a coup would undermine the aspirations and achievements of the 2011 revolution.

Travel warning, evacuation

The U.S. Embassy in Cairo ordered the mandatory evacuation of all nonessential personnel, CNN's Jill Dougherty reported, citing a senior administration official.

Separately, the State Department warned Americans to defer travel to Egypt and U.S. citizens living there to leave the country.

CNN's Ivan Watson and Jill Dougherty contributed to this report.