CAIRO — The Muslim Brotherhood declared early today that its candidate, Mohammed Morsi, won Egypt’s presidential election, even as the military handed itself the lion’s share of power over the new president, enshrining its hold on the state and sharpening the possibility of confrontation with the Islamists.

With parliament dissolved and martial law effectively in force, the generals made themselves the country’s lawmakers, gave themselves control over the budget and will determine who writes the permanent constitution that will define the country’s future.

But as they claimed victory over Hosni Mubarak’s last prime minister, Ahmed Shafiq, the Brotherhood challenged the military’s power grab. The group warned that it did not recognize the dissolution of parliament or the military’s interim constitution – or its right to oversee the drafting of a new one.

That pointed to a potential struggle over spheres of authority between Egypt’s two strongest forces.

The Brotherhood has campaigned on a platform of bringing Egypt closer to a form of Islamic rule, but the military’s grip puts it in a position to block that. Instead any conflict would likely center on more basic questions of power.

At a pre-dawn news conference today declaring their win, officials from the fundamentalist group that was banned for decades and repeatedly subjected to crackdowns under Mubarak’s rule were ebullient and smiling, as supporters chanted, “Down with military rule.”

“Thank God, who guided the people of Egypt to this right path, the path of freedom and democracy,” Morsi told the crowd at his campaign headquarters in his first appearance since the victory claim.

Final official results are not expected until Thursday. The Brotherhood’s declaration was based on results announced by election officials at individual counting centers, where each campaign has representatives who compile the numbers and make them public before the formal announcement.

The Brotherhood’s early, partial counts proved generally accurate in last month’s first-round vote.

The group said that Morsi took 51.8 percent of the vote to Shafiq’s 48.1 percent out of 24.6 million votes cast, with 98 percent of the more than 13,000 poll centers counted.

The question now will be how a Brotherhood president will get along with the military generals who have ruled since Mubarak fell on Feb. 11, 2011 and who will still hold powers that can potentially paralyze Morsi.

The Brotherhood has reached accommodations with the generals at times over the past 16 months, as it struck deals with Mubarak’s regime itself – gaining it a reputation among critics as willing to sell out for a taste of authority.

But after a highly polarized presidential election and the miltary’s arrogation of powers to itself, the Brotherhood presented itself as willing to get into a confrontation with the Supreme Council of the Armed Forces, the body of top generals.