CNN-Mohamed Morsi was declared the new president of Egypt on Sunday in an announcement that triggered massive cheers in Cairo's Tahrir Square.
Morsi, of the Muslim Brotherhood, beat out Ahmed Shafik, who served as the last prime minister under ousted President Hosni Mubarak.
Morsi had more than 13 million votes, while Shafik had more than 12 million, election officials announced.
Both candidates had already declared victory in the hours before announcement.
Authorities in Egypt had been on "high alert" in advance of the announcement, concerned about what could happen if Shafik won. Officials had said they were ready to carry out long-standing policy of using deadly force against people who attack government buildings, officials said.
Instead, the streets of Cairo were filled with celebration -- even in scorching temperatures near 100 Fahrenheit.
The square was the site of mass protests last year that toppled Mubarak.
The presidential race brought Egypt's first democratic elections, which the United States described as historic. But the campaigns of both Shafik and Morsi accused each other of election fraud.
The Muslim Brotherhood announced in advance Sunday that it would stage a long-term protest if Shafik was declared the winner.
The announcement came amid heightened concerns that Shafik would give new life to the old guard and essentially nullify democratic gains since last year's revolution ended Mubarak's 30 years of rule.
"Did we really have a revolution if Shafik wins?" prominent novelist Alaa al-Aswany said via Twitter. "For the thousandth time this is not a battle between the military and the (Muslim) Brotherhood, it is a battle of the Egyptian people with the military regime that ruled us with an iron fist for 60 years."
Like Mubarak, Shafik is a former air force officer with close ties to Egypt's powerful military and is "the quintessential candidate of the counter-revolution," said Khaled Elgindy, a visiting fellow at the Brookings Institution in Washington.
Morsi, an American-educated engineer, "represents the older, more conservative wing of the Brotherhood and openly endorses a strict Islamic vision," said Isobel Coleman of the Council on Foreign Relations.
But in an interview with CNN, Morsi said, "There is no such thing called an Islamic democracy. There is democracy only. ... The people are the source of authority."
A national security officer predicted violence if Shafik is declared the victor.
"In the event of Shafik's win, we expect some trouble on the street and in Tahrir (Square), which will be met with an iron hand according to the instructions we have received," said Lt. Col. Usama Emam.
"We are on high alert and so far there has not been any evidence of an imminent threat or plan of sabotage from any Islamist extremist groups," Emam said. He added that Egyptian authorities have arrested "elements" of the Palestinian group Hamas over the past week since Egypt's military rulers isued "de facto martial law and we are still tracking some of their fugitive members who had entered mainly through Sinai and made their way to Cairo."
More than 1,800 ambulances have been dispatched across the country as a proactive measure, the state-run EgyNews agency reported. It also said the country's interior ministry stressed the need to respect peaceful demonstrations.
But the ministry also said it would not tolerate any turmoil against authorities after Sunday's pivotal announcement.
"Minister Mohamed Ibrahim has given police forces orders to shoot to kill against anyone attempting to attack police stations after the results," interior ministry spokesman Gen. Marwan Mustapha said, reiterating government policy in such circumstances. "Increased security has been dispersed in the side streets of (Cairo's) Tahrir Square to protect government buildings."
The Muslim Brotherhood vowed it would stage "a long-term, open-end sit-in at Tahrir Square," complete with bathroom facilities made of bricks, daily food supply and tight security at the entrances of the square, said Jihad Haddad, a political adviser to the Muslim Brotherhood. Haddad cited the Brotherhood's disapproval of the ruling military body's new constitutional decree and de facto martial law.
Egypt's all-powerful military leaders have said they won't reverse their widely deplored constitutional and judicial changes and also cautioned against election-related unrest.
"We will face anyone who will pose a challenge to the public and private sectors with an iron fist," the Supreme Council of the Armed Forces (SCAF) said.
Egypt's constitutional court dissolved the lower house of parliament this month, extending the military's power and sparking accusations of a coup d'etat.
Both presidential candidates claim victory in Egypt
Adding to the electoral tension is the question of how much power the new president will actually wield now that the military council has full legislative authority.
Under an interim constitutional declaration, the military council retains the power to make laws and budget decisions until a new constitution is written and a new parliament elected.
The declaration said Supreme Council members "shall decide all matters related to military affairs, including the appointment of its leaders." The president has the power to declare war, it says, but only "after the approval" of the Supreme Council.
The military council said it does not favor one political entity over another and respects the rights of Egyptians to protest but stressed the importance of self-restraint and respect for authority.
The Supreme Council urged political entities to respect democracy and "abstain from all possible acts that may descend the country into a full chaos."
Egyptian reform leader Mohamed ElBaradei -- the former head of the United Nations nuclear watchdog agency and a Nobel Peace Prize laureate -- warned that if Shafik was declared the winner, "we are in for a lot of instability and violence ... a major uprising."
He said there were fewer security concerns about a Morsi victory because Shafik supporters were unlikely to take their anger to the streets.
ElBaradei described the current situation as "a total, complete 100% mess."
Mohamed Mahsoob, a law professor at Menofiya University and a member of the El Wasat Party, tweeted: "The revolution will succeed, even if the newly elected president is below expectations because we will have the right to change him. But the revolution will not succeed if we have a president from the old regime that we toppled because he will working on seizing it back (and) reversing the accomplishments."
Amr Moussa, who served as foreign minister under Mubarak and mounted an effort to win the presidency in these elections, said "the next Egyptian president must call upon everyone to stand united as one." According to state-run news agency MENA, Moussa called on the new president "to head an emergency government of technocrats" that would last six to 12 months.