Of all those shocked by Hamas' landslide Palestinian election victory, few were more stunned than the militant Islamist group itself.
A key question hanging over the outcome is which Hamas people voted for -- the radical group that professes eagerness to continue the armed struggle against Israel, or the Hamas that symbolizes, for many Palestinians, the hope for a less corrupt government and a better life after years of conflict?
With trademark discipline, Hamas' senior figures quickly closed ranks Thursday, proclaiming readiness to take on the daunting task at hand. "We will put the Palestinian house in order," said Ismail Haniya, a self-possessed former university dean who was the top candidate on the Hamas slate.
But in many ways Hamas appears ill-equipped to meet this challenge. Its political experience is strictly local -- running the cities and towns where it won municipal elections over the last year. Much of its senior leadership is dead, assassinated by Israel in response to the group's campaign of suicide bombings, in hiatus for the last year.
Complicating matters, foreign donors are poised to shun a Hamas-led government. And its military wing, the Izzidin al-Qassam Brigades, shows no inclination to disarm.
In taking the reins of power after participating in its first parliamentary vote, Hamas leaders face a predicament. If they attempt to please their most radical followers by continuing to call for Israel's destruction, they jeopardize hard-won international support for a Palestinian state.
But if they moderate their stance and reject their founding principle, they risk alienating their militant base.
The group had wrestled with the question of whether to even participate in the parliamentary elections, because such a step implied acceptance of the 1993 interim peace accords with Israel under which the ruling Palestinian Authority was created.
Having won a majority of seats in the new parliament, Hamas has the responsibility of forming a government to work alongside Palestinian Authority President Mahmoud Abbas. Elected a year ago, Abbas will remain in office unless he follows through on threats to resign if he cannot pursue his goal of peace with Israel.
In some respects, Hamas may be better suited to run the Palestinian Authority than Fatah, which was riddled with graft and largely ineffectual under the long reign of the late Yasser Arafat.
For years Hamas has administered a large, efficient network of charities, schools and health clinics, winning a reputation for fiscal integrity along the way. Many of its candidates are well-educated professionals, and not all are ardently religious. Also, Hamas' military wing is thought to be much more accountable to the group's overall leadership than are the roving gangs of gunmen who claim allegiance to Fatah.
Hamas, as it is prone to do, sent mixed signals Thursday about its intentions.
"The Israeli occupiers should recognize Palestinian rights first," Haniya said when asked whether the group would be willing to talk to Israel.
But almost in the same breath, he seemed eager to convey a message of conciliation. Asked what he would say to the United States and other nations that have expressed alarm over the group's ascent to power, he said: "Don't be afraid.... Hamas is an open movement" -- suggesting, apparently, that its stance on matters, including Israel, could change.
Hamas, by dint of its formidable organizational skills, was probably the first to recognize the political earthquake that had occurred with Wednesday's vote. After the polls closed, it posted observers at each site where votes were being counted.
The tallying was slow and painstaking, carried out in some cases by candlelight because of power outages, not unusual in Gaza. But by 3 a.m., Haniya, huddling with aides, receiving reports from the field, talking nonstop on his cellphone, was beginning to put out the shocking news: We won.
Amid the rejoicing, there was a distinct air of nervousness, even outright apprehension, in Hamas-dominated districts of Gaza. A few people wondered aloud: Had Hamas bitten off more than it could chew?
"You know, I was very happy when I went to sleep, when I thought we did well, but not win," Ashraf Kholi, a resident of Gaza City, said. Like many Palestinians, he had tuned into late-night exit polls that gave Hamas perhaps one-third of the vote.
"Then I woke up," continued Kholi, who runs a shop in the city's Zeitun district, home to many Hamas leaders. "And I realized everything had changed."
Hamas is capable of effortlessly marshaling crowds of tens of thousands for street rallies -- and often, in the last five years of fighting, for massive funeral marches. By comparison, Thursday's celebrations were muted and at night, after the election results became official, the streets of Gaza City were almost eerily quiet.
A few scattered truckloads of armed men, green Hamas banners flapping in the salty breeze, fired weapons into the air. A small crowd rallied outside Haniya's house. But neighborhood Hamas activists said they had been told not to mobilize marchers for mass victory celebrations -- at least, not yet.
That may be because Hamas leaders recognize that this is a delicate moment.
To avoid governing alone, and the direct contacts with Israel and the United States that could entail, the group's leaders are trying to woo Fatah into some kind of alliance, an offer that has thus far been spurned.
"It is better to be in the opposition," said senior Fatah leader Jibril Rajoub, a tough former security chief. As to the prospect of Hamas presiding over the sprawling and notoriously inefficient Palestinian Authority bureaucracy, he snorted: "Let them try."
Hamas' rivals believe that the group's triumph does not mean Palestinians want to see a return to violence.
"I still believe a majority of Palestinians do not support the extremists," said Hussein Sheik, who headed Fatah's unsuccessful campaign. "Surveys show 70% of the people supported the calm, and 75% support peace in return for a Palestinian state in Gaza and the West Bank. The Palestinians want peace."
Sufian abu Zaida, the Palestinian minister for prisoner affairs, said he believed that in the end, Hamas would choose the path taken by Arafat's Palestine Liberation Organization: agreeing to accept Israel's existence.
"The PLO also resisted changing its charter for over 30 years, but in the end there is political reality, and one must be realistic," he said.
But other realities could also intrude. The vast patronage empire of the Palestinian Authority cannot be dismantled overnight. Already, Hamas is hinting that Fatah rank-and-file loyalists could find themselves forced out of bureaucratic and security jobs, a move that could set off an explosion of violence.
"Starting tomorrow, who is going to pay the salaries of 150,000 civil servants without money from donor countries, who will almost certainly stop giving them money?" asked Amnon Lipkin-Shahak, a former Israeli army chief of staff who has participated in negotiations with the Palestinians.
Many believe that the biggest obstacle to any hope of a smooth transition of power will be the simple fact of desperate hardship in Palestinians' daily lives: poverty and unemployment, roadblocks and checkpoints.
Ghassan Khatib, the Palestinian planning minister, said he doubted that Hamas could do better than Fatah, but "not because they are incompetent."
"Anybody who is living under the conditions in which we are living will not be successful," he said.
Times staff writer Ken Ellingwood in Ramallah contributed to this report.