US-backed Iraqi forces on Tuesday said they were making gains in their ongoing push to dislodge fighters from the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) group from the northern city of Tal Afar, as the Pentagon chief made a surprise visit to Iraq in a show of support.

The joint Iraqi forces took control of al-Jazirah area, on the eastern side of Tal Afar, as troops and members of the Shia Popular Mobilisation forces started heading towards the city centre, a security source told the DPA news agency.

ISIL fighters, estimated to number up to 1,000, reportedly responded with artillery fire, as government forces massed outside the city. The city has been under ISIL control since 2014.

MAPPED: The battle against ISIL

Al Jazeera's Osama bin Javaid, reporting from Erbil in northern Iraq, quoted military sources as saying that forces are moving in from the western and northeastern front of the city, adding that they have taken control of an oil refinery "and breached the city's walls".

"Their movement was swift earlier, but now the real battle begins," he said on Tuesday, the third day since the start of the offensive.

Army, police and units of the Popular Mobilisation forces also took "full control" of Tal Afar's al-Kifah and al-Nur districts, Popular Mobilisation spokesman Ahmed al-Assadi was quoted by the AFP news agency as saying.

Assadi said Iraqi forces had encircled the city despite "intense" fighting, adding that the offensive would likely last for weeks.

In his weekly press conference, Iraqi Prime Minister Haider al-Abadi described Tuesday's progress as "excellent", calling it an "indication of the enemy's collapse".

Tal Afar, located some 70km west of the recently recaptured city of Mosul, is a key ISIL hub between Iraq's second largest city and the Syrian border.

In July, Iraqi troops, supported by the forces of a US-led coalition, routed ISIL in Mosul, allowing it to advance into Tal Afar on Sunday. ISIL still controls other areas in the south and west of Mosul.

The latest offensive has forced thousands of people to flee to the country's Kurdish region, according to the United Nations.

On Tuesday, Al Jazeera's bin Javaid reported that fleeing residents had to travel 10 to 20 hours to escape the fighting.

"It's a very desperate picture. Some people weren't even fully-clothed ... as they tried to reach safety," he said.

Since Friday, more than 3,000 people had arrived at two emergency sites, many with just the clothes on their back, according to the International Organization for Migration (IOM).

"These internally displaced persons (IDPs) carried a minimal amount of clothes; some only had what they wore, some were partially clothed," IOM said in a statement, adding that thousands more are expected to flee in the coming days.

Most of the residents had to walk for hours in arduous conditions before reaching safe areas, the statement said. Many "arrive exhausted and in poor health, often with critical levels of malnutrition among children, some unable to move."

UNHCR, the UN's refugee agency also said it had received some 9,000 people at the Hamman al-Alil transit centre in the past week, and it was preparing to accommodate nearly 30,000 more.

"Food and water are running out, and people lack the basic necessities to survive," said Lise Grande, the UN's humanitarian coordinator in Iraq, adding that families are trekking "in extreme heat to reach mustering points. They are arriving exhausted and dehydrated".

Mattis visit

As the fighting continues, US Defence Secretary James Mattis, who made an unannounced visit to Iraq, declared that "ISIS is on the run", following his meeting with Iraqi Prime Minister Haider al-Abadi in Baghdad.

"Today, the security for the Iraqi people has been greatly improved," Mattis said. "Cities have been liberated. People are free from ISIS ... the economy is recovering."

But Mattis declined to make any predictions on the battle.

"ISIS's days are certainly numbered, but it's not over yet, and it's not going to be over anytime soon," he said.

Mattis then left for Erbil, the capital of Iraq's Kurdish semi-autonomous region, where he is scheduled to hold a meeting with President Massoud Barzani.

A key sticking point in the meeting is Iraqi Kurdistan's plan for an independence referendum on September 25, strongly opposed by the US and Baghdad.

Barzani, who has so far resisted international pressure to delay the referendum, said the vote would not be postponed "for the Kurds' own good" despite reports that the US administration is critical of the vote, according to Kurdish news website Rudaw.

"Waiting for Baghdad to approve the referendum is dangerous," said Barzani. "The Kurds have agreed to start a new page with Baghdad, but the Baghdad government's mentality has not changed," he added.

The Iraqi constitution "gives us the right to self-determination."

Brett McGurk, the White House envoy to the anti-ISIL coalition, told the Associated Press news agency that a referendum at this time "would be potentially catastrophic to the counter-ISIS campaign".