Running a school in the enclave controlled by Syria's al-Qaeda affiliate, Syrian-American Rania Kisar has become skilled in getting her way, either by negotiating with the militants or by pushing back against them.

When she was preparing for the students' graduation, the militant group sent an inspector who told her not to play music at the ceremony. She argued back. Then on graduation day, she invited the group.

The ceremony started with a nod to tradition with a Quranic recital in line with the inspector's wishes. But then as the students filed out in front of an audience of relatives and local officials, as well as representatives from the militant group, Kisar played “Pomp and Circumstance” — the anthem used at American graduations.

It was a calculated gamble: she was betting the militants would not make a scene.

“It was matter-of-fact. They did nothing,” she said. But she knew why they had intervened in the first place. “If they don't interfere, they won't be considered powerful,” she said.

​Idlib province in north western Syria is the last major stronghold of the rebellion that erupted in 2011 against President Bashar al-Assad. Al-Qaeda's branch is the strongest force in the territory: it leads an alliance of factions known as Hayat Fatah al-Sham and dominates the administration set up by the opposition to run the province.

But the group has to tread carefully, balancing between its aim to control and its wariness of triggering a backlash from residents and other factions. So far, it has stayed relatively pragmatic: it takes every opportunity to show it is in charge but has shown no interest in a wide-scale imposition of an extremist vision of Islamic law.

They halted public killings of criminals; there are no religious police patrolling streets, arresting or beating people — and they haven't forced women to wear the niqab face veil.

That is a sharp contrast to the Isis in the stretches of Syria and Iraq where the rival militant group has ruled the past three years.

Instead, al-Qaeda administrators and fighters try to enforce some rules on a smaller scale while avoiding heavy-handed confrontation and presenting themselves as the champions of Syria's “revolution” against Assad.

Idlib now stands in a tenuous position among the international and regional powers that are effectively carving up Syria.

​Assad's military had threatened an offensive on Idlib but is now focused elsewhere, against Isis militants to the east. Turkish troops and their Syrian allies who control parts of neighbouring Aleppo province were reportedly mobilising to move into Idlib — prompting sharp warnings from Hayat Fatah al-Sham against any attempt to do so. The United States is also focused on its own campaign against Isis with the assault on Raqqa, and it is unclear how it and Assad's ally Russia want to deal with Idlib in the future.

In the meantime, Idlib, swelling with more than 900,000 Syrians displaced from other parts of the country, is the refuge of an opposition movement that hoped to create a new Syria and only a few years earlier appeared to have the momentum in the conflict.

Now Kisar and others like her are trying to keep al-Qaeda's influence at bay.

“Everyone sold us out,” she said in a recent interview in her office in Istanbul, where she regularly travels.

Kisar said the international community's fear of radical Islamists taking over Syria is exaggerated and reflects a lack of understanding of the Syrian opposition. She and others argue that the militants are needed, they provide services and infrastructure as well as skilled fighters for now, but will not have support later.

From the start, Kisar has been a true believer in the uprising. After the revolt began in 2011, she left her administrative job at a Dallas university and joined the opposition.

She traveled with fighters on the front lines, helping displaced people. She organised services in opposition territories. Along the way, she survived an air strike and lost a colleague who was kidnapped by Isis militants and was later believed killed.

Finally, she settled in Maaret al-Numan, Idlib's second largest city. It was one of the few strongholds of the moderate Free Syrian Army, the umbrella group for the internationally-backed opposition factions. In recent years, radical factions like al-Qaeda have grown in influence and gained a foothold. But Maaret's residents largely continued to support the FSA. They held repeated protests whenever al-Qaeda fighters went too far, arresting journalists or cracking down on opponents.

In 2015, Kisar launched her foundation — SHINE, or the Syrian Humanitarian Institute for National Empowerment.

It provides classes for adults in computers, programming and web design. Registered in Dallas and funded by donations from Turkey and private citizens in America and elsewhere, the foundation has so far graduated 237 students.

Kisar takes great pride in the result: a “geek squad” of tech-savvy men and women who can fix smart phones and computers. That is vital in opposition-held areas, where there are no telephone lines and the population relies on satellite internet for communication.

“There are no private institutes, no universities, there are no hospitals,” she said. “It is us, a bunch of locals, volunteers, stepping forward and saying, OK, I am going to clean the street, I am going to go volunteer in a hospital and I am going to build a school... This is my part. This is my honour.”

Her first brush with the militants came when she had to explain her work to gain accreditation from the bureaucracy they control.

She bickered with one official, arguing that armed groups should not control civilian affairs. He wouldn't look her in the eye since she's a woman. But “when he heard I am from America, he said: 'We have every honor that an American Muslim is here and wants to be here',” she recalled.

Even in heated debates with the militants, she said, she has always kept a respectful tone, something that has helped keep her operating.

It also helps that she is a woman. “I can get away with a lot of things,” she said with her characteristic giggle. “There is a lot more leniency toward me because I am a woman.”

The ultraconservative militants were concerned that SHINE provides classes for men and women. So she negotiated to keep it going by segregating the space — men on the bottom floor, women on the top. When air strikes hit the top floor, she set up separate areas on the ground floor.

The militants sent inspectors to ensure classes observed their interpretation of Islamic laws. The strictly computer-focused program had nothing that would offend them, she said. “They want to interfere in everything,” she added.

Hayat Fatah al-Sham is increasingly intervening in day-to-day affairs in Idlib and in civil society groups, confiscating goods and taking control of exchange bureaus, said Sam Heller, a Syria fellow at the Century Foundation. Its attempts to seize a role in provision of relief aid have alarmed the aid community, he said.

At the same time, it is struggling between its identity as a hard-line jihadi movement and its ambition to lead the rebellion with its variety of factions, wrote another Syria watcher, Mona Alalami in a recent Atlantic Council article.

When that balancing act breaks down, violence can explode.

In June, Maaret al-Numan was shaken when pitched street battles erupted between al-Qaeda militants and the FSA, bringing gruesome revenge killings and leaving at least six civilians dead. HTS fighters opened fire on residents protesting against their presence in the streets.

For a moment, the chaos seemed to shatter Kisar's spirit. “It is going to break loose,” she said over the phone at the time. “Everybody is fighting everybody.”

She left town for several days to “breathe.”

Aleppo before the Syrian Civil War Show all 12 1 /12 Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War A man crosses a street in Aleppo, December 12, 2009 Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War A vendor sits inside an antique shop in al-Jdeideh neighbourhood, in the Old City of Aleppo, December 12, 2009 Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War A view shows part of Aleppo's historic citadel, overlooking Aleppo city, Syria Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War A view shows part of Aleppo's historic citadel, Syria Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War Visitors walk inside Aleppo's Umayyad mosque, Syria Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War People walk inside the Khan al-Shounah market, in the Old City of Aleppo, Syria Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War A man walks past shops in al-Jdeideh neighbourhood, in the Old City of Aleppo, Syria Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War People walk along an alley in al-Jdeideh neighbourhood, in the Old City of Aleppo, Syria Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War Visitors tour Aleppo's historic citadel, Syria December 11, 2009 Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War A general view shows the Old City of Aleppo as seen from Aleppo's historic citadel, Syria December 11, 2009 Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War People walk near Aleppo's Bab al-Faraj Clock Tower, Syria October 6, 2010 Reuters Aleppo before the Syrian Civil War Aleppo before the Syrian Civil War A man stands inside Aleppo's historic citadel, overlooking Aleppo city, Syria December 11, 2009 Reuters

Eventually, calm was restored with a shaky reconciliation, though one that increased the militants' influence: the FSA faction running the town had to leave their offices, replaced by an agency linked to al-Qaida.

Kisar resumed her work — and her own balancing act. This time, she was preparing festivities for local children to celebrate a major Muslim holiday.

“You must check out the videos,” she said, giggling. “It is like Disneyland. It is SHINEland. It is majestic.”