CAIRO — Election regulators named Mohamed Morsi of the Muslim Brotherhood the winner of Egypt’s first competitive presidential elections, handing the Islamist group a symbolic triumph and a new weapon in its struggle for power with the ruling military council.

After an hourlong speech in which he detailed dozens of specific inquiries down to the ballot-box level, the chairman of the election commission, Farouk Sultan, announced that Mr. Morsi had won 51.7 percent of the runoff vote completed last weekend. The other candidate, the former general Ahmed Shafik, won 48.3 percent.
In Tahrir Square, where hundreds of thousands had gathered to await the result, the confirmation of Mr. Morsi’s win brought instant, rollicking celebration. Fireworks went up over the crowd, which took up a pulsing, deafening chant: “Morsi! Morsi!”
Mr. Morsi now becomes the first Islamist elected to be head of an Arab state. But his victory is an ambiguous milestone in Egypt’s promised transition to democracy after the ouster 16 months ago of President Hosni Mubarak.
After an election that international monitors called credible, the military-led government has recognized an electoral victory by an opponent of military rule over Mr. Shafik, who promised harmony with the Supreme Council of the Armed Forces. But Mr. Morsi’s recognition as president does little to resolve the larger standoff between the generals and the Brotherhood over the balance of power over the institutions of government and the future constitution. Under the generals’ plan, Mr. Morsi, 60, will assume an office stripped of almost all authority under a military-issued interim constitution.
Having dissolved the democratically elected and Brotherhood-led Parliament on the eve of the presidential vote, the generals who seized control after Mr. Mubarak’s ouster abrogated their pledge to hand power by June 30, eliciting charges of a new military coup.
After 84 years as an often outlawed secret society struggling in the prisons and shadows of monarchs and dictators, the Brotherhood is now closer than ever to its dream of building a novel Islamist democracy. And its leaders vowed to fight on for the restoration of Parliament regardless of Mr. Morsi’s win.
Although it was clear as early as Monday morning that Mr. Morsi had won more votes than Mr. Shafik, the weeklong delay in the official results stirred widespread fears that the military-led government might seek to name Mr. Shafik as a decisive blow in the generals’ power struggle with the Brotherhood.
Before the results were announced, the capital was as tense Sunday as on any day since the two and a half week revolt that brought down Mr. Mubarak. Army tanks and soldiers were deployed around the election commission, the Parliament and other institutions to prepare for possible violence. Foreign embassies warned their citizens to stay away from downtown. Banks, government offices and schools all closed early to allow students and employees to get off the streets.
His designation as president-elect will hand the Brotherhood and its allies a bully pulpit to use the struggle for power with the military. The Brotherhood has sought to rebuild the partnership with more secular and liberal advocates of democracy that came together in the uprising against Mr. Mubarak, and Brotherhood leaders have vowed not to hold any negotiations with the generals without the participation of the other groups in their so-called “national front.”
But on its own, the Brotherhood’s control of the presidency will do nothing to reduce the calm the fierce polarization of Egyptian society. On Saturday night, a counter protest that reportedly grew to over 10,000 gathered in a neighborhood with a heavy concentration of military personnel to demonstrate in support of the ruling generals, Mr. Shafik and secular government. Mr. Shafik, Mr. Mubarak’s last prime minister, has campaigned with the support of the old ruling party elite as a new strongman who can bring back order after the 16 months of chaos.
Earlier in the day, a group of secular political leaders and lawmakers who call themselves liberals had held a televised news conference to declare their support for the generals and the dissolution of the Brotherhood-led Parliament. The praised the shutdown of parliament as a victory for law and order, citing an unusually rushed court decision announced the day before. (The Brotherhood has respected the ruling but challenged its implementation.)
The secular politicians also accused the Brotherhood of “hijacking” the revolution and called it a threat to the “civil” character of the state. They dismissed the Brotherhood’s pledges to govern in coalition, respecting individual and minority rights, and instead accused the group of plotting to impose religious rule.
Incongruously given Washington’s history of antagonism with the Islamists of the Muslim Brotherhood, the secular block argued that the United States was improperly attempting to sway the presidential race in favor of the Brotherhood, although American officials and the embassy have said they support only the democratic process regardless of the result.
In an apparent effort to reassure Egyptians skeptical of the Brotherhood’s intentions, Mr. Morsi on Sunday made good on a campaign pledge to resign from his positions in the Brotherhood and its Freedom and Justice Party, the Brotherhood announced via Twitter.
Mr. Morsi is an American-educated engineer who received his doctoral degree at the University of Southern California. He once led the Brotherhood’s small bloc of lawmakers in the Mubarak-dominated parliament, and, like many Islamists under the old regime, was occasionally jailed for his political activities
But his candidacy was largely accidental. He was chosen at the last minute to represent the Brotherhood after the disqualification of the group’s preferred candidate, Khairat al-Shater, who was declared ineligible. On the campaign trail, Mr. Morsi exuded little charisma even as he espoused polarizing conservative views, promising to institute Islamic law and calling for a review of Egypt’s 1979 peace treaty with Israel.
Amid the crackling of fireworks and shouts of “Akbar! Akbar!” that erupted from Mr. Morsi’s supporters on Tahrir Square and elsewhere on Sunday, some, especially the Web-savvy youth that played a dominant role in ousting Mr. Mubarak, expressed trepidation about the aftermath of the announcement even as they welcomed the defeat of a stalwart of the old regime.

“I know a lot of people are celebrating a