Iraq’s special forces fought their way into the outskirts of Mosul on Tuesday, taking its state television building despite resistance by Islamic State group fighters that is only likely to stiffen when combat reaches the inner city.

It was the first time Iraqi troops have set foot in the city, Iraq’s second-largest, in more than two years. The advance was the start of what is likely to be a grueling and slow operation for the forces as they fend off booby traps and ambushes in difficult, house-to-house fighting expected to take weeks, if not months.

Troops entered Gogjali, a neighborhood inside Mosul’s city limits, and later the outskirts of the more built-up Karama district, according to Maj. Gen. Sami al-Aridi of the Iraqi special forces. As the sun went down, a sandstorm blew in, reducing visibility to only 100 meters (yards) and bringing the day’s combat to an end.

"Daesh is fighting back and have set up concrete blast walls to block off the Karama neighborhood and our troops’ advance," al-Aridi said, using the Arabic acronym for the Islamic State group. He said bombs have been laid along the road into the city.

Later, al-Aridi said the troops had taken the state television building, the only one in the province, and that heavy fighting broke out when they tried to continue further into built-up areas. An official casualty report was not given, but officers mentioned one dead and one wounded.

Mosul is the last major IS stronghold in Iraq, the city from which it drove out a larger but demoralized Iraqi army in 2014 and declared a "caliphate" that stretched into Syria. Its loss would be a major defeat for the jihadis, but with the closest Iraqi troops still some 10 kilometers (six miles) from the city center, much ground remains to be covered.

Tuesday’s battle opened with Iraqi artillery, tank and machine gun fire on IS positions on the edge of Gogjali, with the extremists responding with guided anti-tank missiles and small arms in an attempt to block the advance. Airstrikes by the U.S.-led coalition supporting the operation added to the fire hitting the district.

Col. John Dorrian, spokesman for the U.S.-led coalition, said that aerial observations of the battlefield showed that IS forces can no longer move in large numbers.

"If Daesh stand and fight, they’re going to be killed. There’s no question about that. If they run, they will either be captured or killed. They are not going to be allowed to escape," he said in a televised news conference with Iraqi forces in Qayara, south of Mosul.

"When we see them come together where there are significant numbers we will strike them and kill them."

Smoke could be seen rising Tuesday from buildings in Gogjali, where shells and bombs had landed. IS-lit fires also sent plumes of dark smoke into the sky, in an attempt to obscure coalition warplanes’ view of the city.

Inside the village of Bazwaya, five kilometers (three miles) east of Mosul, white flags hung from buildings, put up a day earlier by residents eager to show they would not resist the Iraqi forces’ advance. Some residents stood outside their homes, and children raised their hands with V-for-victory signs.

The families, estimated to number in the hundreds, will be evacuated from the village to a camp for displaced persons, said Brig. Gen. Haider Fadhil of the Iraqi special forces.

As the fighting raged on Mosul’s outskirts, several of the newly displaced from Bazwaya could be seen carrying white flags as they drove a herd of some 150 sheep toward the camp.

Emad Hassan, a 33-year-old former policeman, said he came to Bazwaya when the operation to retake Mosul started after fleeing IS fighters in the city.

"When I knew the security forces were serious about liberating Mosul, I came here," he said. "Daesh was preventing families from moving toward the security forces and ordered them into the city center, but I refused."

For more than two weeks, Iraqi forces and their Kurdish allies, Sunni tribesmen and Shiite militias have been converging on Mosul from all directions to drive IS from the city.

The forces have made uneven progress in closing in on the city. Advances have been slower to the south, with government troops still 20 miles (35 kilometers) away. Kurdish fighters and Iraqi army units are deployed to the north, while Shiite militias are sweeping in from the west to try to cut off any IS escape route.

The Iranian-backed Shiite forces, known as the Popular Mobilization Units, are not supposed to enter Mosul, given concerns that the battle for the Sunni-majority city could aggravate sectarian tensions. Live video provided by the militias to The Associated Press showed dozens of vehicles, including militia tanks, advancing toward Tal Afar, a town to the west of the city.

Meanwhile, the army’s ninth division was moving toward Mosul on a path cleared by the special forces, and was approximately three kilometers (two miles) from its eastern outskirts.

The U.S. military estimates IS has 3,000 to 5,000 fighters in Mosul and another 1,500 to 2,500 in its outer defensive belt. That total includes about 1,000 foreign fighters. They stand against an anti-IS force of some 40,000, including army units, militarized police, special forces and Kurdish fighters.

The foreign fighters are a source of particular ire for the Iraqi troops and have given them "big motivation" to liberate Mosul, Gen. Talib Shaghati al-Kenani told an AP reporter accompanying the Iraqi forces.

"We are listening to and are able to access their communications. There are fighters from Uzbekistan, Turkey and many other nationalities. Those are a group of terrorists who fight Iraqis and usurp their cities," he said.

A video published online by IS purported to show life inside Mosul’s Karama district just a day earlier. Released by the militant’s Aamaq news agency, the footage showed residents insisting that life was normal and that no anti-IS forces had entered the neighborhood.

"We hear the thud of the bombs fired by our brothers" at the Iraqi forces, said a bearded man in a wheelchair on a market street where taxis and shoppers passed by unimpeded.

As the Mosul offensive has pressed on, bombings have continued in the capital, Baghdad, part of a sustained IS effort to destabilize the country. Dozens have been killed since the push on Mosul started in apparent retaliation attacks, mostly claimed by IS.

Violence is still rampant across the country, with killings worsening in October, the United Nations said. A monthly report released by the U.N. Assistance Mission for Iraq said 1,792 people were killed in October, up from 1,003 the previous month. It said 1,120 of the dead were civilians.

The worst-hit city was Baghdad, with 268 civilians killed and 807 wounded, while militant-held Ninevah province was next, with 566 killed and 59 wounded. The U.N. didn’t say whether the Mosul operation was directly related to the casualties in Ninevah, its surrounding province.