People inspect the damage after an attack by Islamic State militants in the city of Kirkuk, Iraq, October 22, 2016.

Reuters/Ako Rasheed

A rescue mission led by the Iraqi security forces miraculously extracted about 30 girls trapped in a Christian school building in Kirkuk, Iraq that ISIS attacked early Friday morning.

In the unexpected attack, dozens of ISIS fighters stormed through the city, turning it into a battle zone as the fighting went on from dawn until evening. The Islamic extremists also launched suicide bombs against the police, according to The New York Times.

With the battle going on, the government advised the residents to stay indoors and enforced a curfew.

ISIS fighters invaded several buildings, including a mosque, a hospital and a Christian school ran by Bishop Youssef Touma, which caters to about 500 students.

"The terrorists rushed into the surrounding buildings, including the Dominican nunnery and four homes for the [Christian] students [that] had been chartered by the Archdiocese of Chaldeans," Bishop Touma told CBN News in a statement.

Most of the students were not in the building when the extremists broke in, but there were around 30 girls trapped inside. The Iraqi security forces knew very well the danger the girls were in, as the ISIS attackers were not only heavily armed but had explosive belts attached to their bodies.

Touma said the rescue team planned an extraction for the first 14 girls, which turned out to be successful despite snipers shooting at the Iraqi troops.

The team then planned the rescue of seven more girls. This was a crucial extraction because there were four ISIS fighters occupying the room adjacent to where the girls had been hiding.

The Iraqi troops instructed the girls, who were hiding under their beds, to remain quiet so they will not attract attention. The girls did not move and stayed under their beds for 18 hours.

At 2 a.m., the rescue troops began the extraction, and every single one of the girls was taken out without the extremists in the other room noticing what was going on.

The other remaining girls were also taken out of the building a few hours after the seven were rescued.

The extremists reportedly detonated suicide bombs in the school, but all the girls had been brought out.

Touma said it was a miracle.

"The Lord blinded the terrorists," Touma said. "We thank the Lord for his blessings and because He still makes miracles for His children."

Touma also praised the Iraqi security forces for having the “courage and willingness to sacrifice” as they carried out the mission.

ISIS’ surprise attack in Kirkuk led to 40 deaths, including 30 Iraqi troops and a reporter from Turkmeneli TV, Ahmet Herceroglu.