Hasakeh, Syria: Before jihadists seized his hometown and turned his school into a prison, Syrian teenager Ahmad Mohammad never imagined he would be excited about sitting his final exams.

After a long wait, the 17-year-old and around 650 other teenagers were bussed into the northeastern Syrian city of Hasakeh this month to finally try to obtain their school diplomas.

They travelled around 200 kilometres (125 miles) from several towns in the north of Raqa province that were retaken from the Islamic State (IS) group by Kurdish militia in June.

Mohammad said he had not seen the inside of a classroom since early 2014, when jihadists captured his hometown of Tal Abyad on the border with Turkey and began using it as a gateway to their Raqa stronghold.

"They turned our school into a prison operated by Daesh fighters," he said, using an Arabic acronym for IS.

"My heart would grow heavy when I walked past my school, not allowed to go in. I would remember the good times with classmates the war has scattered across the globe," he said.

"Going back to school brought me back to life... The future looked very dark for me, but that changed today," he added.

Around two million children do not attend school in Syria, the United Nations says, five years into a complex war that has killed more than 270,000 people and sent millions into exile.

In areas under its control, IS has enforced its own self-styled curriculum of religious education coupled with military training.

'We felt like outsiders'

In Hasakeh province, schools are run by either the government or Kurdish authorities who declared an autonomous region in areas under their control after the 2011 uprising against President Bashar al-Assad.

Many of the students who travelled to the region brought heartrending tales of the obstacles they faced to get an education under IS.

"My father is a teacher and he continued teaching us in secret" after school was banned, said a teenager from the town of Suluk in Raqa province.

Tahami Abdullah, a school official in Tal Abyad, said when fighters first entered the town "they asked for teaching hours to be reduced and for some of the subjects to be dropped".

"Then they abolished education completely and transformed schools either into prisons, missions or religious police posts," he said.

He said IS forced many to sign a pledge promising not to teach the Syrian national curriculum.

"They had their own special courses they would teach in their Islamic schools and missions," Abdullah said.

"But no one taught or studied there except for their members and the families of the foreign fighters. We felt like outsiders."

Ibrahim Khalil from Tal Abyad said he had not held a pen or notebook in several years because he was "so afraid IS would cut off my hand."

"Daesh came to spread ignorance, but our will is stronger than theirs and we will study and continue our education."

ISIS 'wants us to be ignorant'

As state institutions collapsed across swathes of Syria, alternative methods of education have filled the void.

The autonomous Kurdish administration that has managed parts of northern Syria since 2012 run their own schools and teach the long-banned Kurdish language.

And opposition-run local councils manage schools in rebel-held areas.

In the battleground second city of Aleppo, schools in opposition-held areas have often been forced to shut for weeks at a time due to intense government bombardment.

The frequent closures as well as mass displacement have sparked fears among rights groups of a "lost generation" of Syrian students.

Ittihad al-Hassan, an 18-year-old female student from Tal Abyad, said she was supposed to sit her ninth grade exams two years ago.

But when IS overran her hometown, the jihadists "banned learning and everything else... because they wanted us to be ignorant."

"They forced us to cover up completely with a face veil. It was even forbidden for us to show our hands."

She said sitting her exam reminded her of "safer days".

Nirouda Mohammed, a Kurdish student who fled from Raqa city to Tal Abyad, said finally being able to sit her exams was a dream come true.

"I missed sitting at a school desk," she said.

"I'm confident that tomorrow, a new sun will rise over my country."