Libya seems relentlessly committed to proving the pessimists wrong. When last year’s revolution quickly evolved into a brutal civil war, the international community — and indeed many Libyans — warned of a quagmire down the road. “God is great” served as the rebel battle cry in the overthrow of Muammar Gaddafi, and the jihadists the dictator had once repressed rose to prominence as militia leaders and politicians in the vacuum left by his fall. Libya has always been a conservative and largely homogenous country; its population of 6 million is almost entirely Sunni Muslim. And that’s why, when Libyans went to vote last weekend in the first national elections since 1965, many observers assumed — with good reason — that if neighboring Tunisia and Egypt had elected Islamist governments in the aftermath of their revolutions, surely Libya — of all places — would follow suit. But in the past 18 months since the start of the Arab Spring, Libya has also served as the Arab world’s anomaly: waging war when others waged protests, overthrowing an entire regime rather than simply its strongman, and most recently, demonstrating remarkable stability despite the odds. As election results trickle in this week, Libya appears poised to buck yet another Arab Spring trend: the Islamist rise.

Weeks after Egypt elected Mohamed Morsy, the first Islamist President in the country’s history — and just months after it elected a parliament dominated by Morsy’s Muslim Brotherhood — Libya has done the exact opposite. Early electoral results indicate that the liberal, secular-leaning National Forces Alliance of Mahmoud Jibril, the former wartime Prime Minister of the rebels’ National Transitional Council (NTC), has swept the majority of the country’s new parliament. Even Libya’s newly empowered Muslim Brotherhood has conceded that it failed to win a majority of the assembly’s 200 seats. And indeed, as the newly elected body moves to select a government to replace the NTC this month, Jibril may well become Libya’s first postrevolution Prime Minister.

All that may have some observers blinking and blindsighted in the Libyan sunlight, but analysts on the ground say it makes more sense than you might think. To start, many Libyans voted along tribal and familial lines, rather than according to ideological alliances. And analysts say that political inexperience may have fragmented support for the Islamists even as Jibril’s broad coalition, benefited from well-known personalities and parties that span the country’s tribes and cities.

But many also point out that Libya’s Muslim Brotherhood, as well as Islamist militia leaders like Abdel Hakim Belhaj — once a terror suspect tortured and extradited by the CIA, and now the head of one of the better-organized political parties — never had the popularity that their counterparts had in neighboring Egypt. After all, Egypt’s ousted authoritarian leader, Hosni Mubarak, had allowed the Brotherhood to cultivate charity networks and even run for parliament. It may have all been part of a decades-long scheme to convince Egyptians and Egypt’s allies that the country’s options for governance were limited to two extremes, but the end result was that the Egyptian Muslim Brotherhood was more prepared. Gaddafi on the other hand never tolerated the Islamists — or even weak political parties. Men with beards or political sympathies were so regularly monitored and rounded up that many Libyans said it was a crime to be religious or have opinions. Few bothered to try.

That rise from exile and repression may have given Libya’s Islamists an early boost when it came to political organizing during the uprising, but it also meant that they were starting at square one — just like everybody else. When TIME met with one of the Muslim Brotherhood’s senior leaders in Tripoli late last year, he admitted that he had no idea how many members the group even had inside the country. “Yesterday was the first time we met in Tripoli not underground,” Alamin Belhaj said shortly after the rebels took control of the capital. “The Brotherhood has been around for a long time, since 1951. But after Gaddafi came, it vanished.”

In the months since, as the Brotherhood and other parties have begun to cultivate a political following, rumors of Islamist funding coming from Arabian Gulf states like Qatar have damaged the group’s nascent image. Posters and protests have sprung from popular opposition to a perceived financial intervention. Libyans may have accepted military assistance from NATO and Qatar in their struggle to defeat Gaddafi, many say, but they’re unwilling to accept a foreign hand in their postrevolution politics.

As for their neighbors? Some say Egypt and Tunisia have provided useful but often counterintuitive examples. Both countries held their first postrevolution parliamentary elections months ahead of Libya. And many political analysts thought the Islamist victories in Tunisia and Egypt would give Libya’s Islamists a surge of popularity and confidence. Instead, those victories may have served as a warning. “I think among a lot of people, after [Muslim Brotherhood candidate] Mohamed Morsy got elected in Egypt, they kind of looked around and wanted to show a sign of independence,” says one foreign NGO worker who has spent the length of the transition in Libya. Libyans saw the Brotherhood rising on a regional level, and the group’s leaders in Egypt and Tunisia even spoke of regional unity. To some, the vote against the Islamists ultimately delivered a reaffirmation of Libya’s autonomy, he says: “That ‘We’re not part of your empire.'”

Jibril, whose coalition stands to lead the new government, has weathered his share of harsh criticism as well. Forging a new government under his leadership will not be easy. Jibril served as an economic adviser to Gaddafi’s regime during its last four years in power, and he resigned at the start of the uprising. Some of Jibril’s harshest critics, most notably people from within the NTC, have accused him of running a deeply corrupt and inefficient transition, and many also say his ties to the ex-regime make him an unreliable pick to move the country forward. In the brief campaign period ahead of last weekend’s vote, many of Jibril’s opponents tried to paint him as a vestige of the Gaddafi era — and a “secular” one at that.

But experts point to the fact that Jibril’s coalition was never decidedly secular in its definition as another reason for his victory. Jibril and other non-Islamist party leaders have said that Islamic law should remain an important source of legislation in the new Libya. And Hana Galal, a member of the country’s National Council of Human Rights and a law professor at Benghazi University, says that despite her mixed feelings about Jibril, his coalition probably beat out the Islamists because it was the most diverse and moderate-sounding option on the ballot. “The coalition has different ideologies, different groups and different personalities,” she says. “It’s not just one ideology, so that may be what made them attractive.”

For better or worse, the NGO official in Tripoli points out, it’s also impossible to discount the national recognition that Jibril earned as a leader during the Libyan revolution. “He was the wartime Prime Minister, and he got NATO involved,” the official says. The fact that Jibril successfully lobbied for international assistance when the rebels so desperately needed it was an achievement that resonated with a lot of Libyans, he says.

Still, it remains entirely hazy what the new parliament will look like, or how well it will be able to appoint a government to unite the country. With no previous local experience in democracy, and many members elected along tribal or family lines, the legislature is bound to include dozens of people whose priorities and politics have been previously unknown on the national level. Galal and many others in the eastern city of Benghazi also worry that those names could include a disproportionate number of old-regime affiliates elected under Jibril’s umbrella group, or that the new government could favor the development of the western region just as Gaddafi’s government did. It was that fear that drove protests, boycotts, and even a few violent clashes in the country’s east on and before election day. And observers say it will likely drive sporadic violence in the weeks and months ahead. But election officials say the turnout was still impressively high at 65% — far higher than in neighboring Egypt — and election monitors have said the process was generally clean. It’s an imperfect experiment in democracy, says Galal. “But at the end of the day, it’s still a step in the right direction.”