By Storay Karimi and Mohammad Stanekzai

HERAT, Afghanistan (Reuters) - Taliban fighters with heavy weapons and night-vision equipment fought their way close to the center of the western city of Farah on Tuesday, as Afghan forces with U.S. air support battled to force them back, officials and residents said.

Residents of the city, capital of Farah province on the border with Iran, have warned for months the city was vulnerable and the attack threatened a repeat of the Taliban's capture of the northern city of Kunduz in 2015.

Local people said Taliban forces began their attack at around 2.00 a.m. (2130 GMT Monday) from several directions and a senior official said the situation was serious early in the day as the insurgents overran several areas and the provincial governor left the city.

However, as special forces units, backed by both Afghan and U.S. air strikes rushed to counter the assault, the situation stabilized later in the day.

Mohammad Radmanish, a spokesman for the defense ministry in Kabul, said the insurgents had been pushed out of the city and reinforcements, including special forces units from neighboring provinces, had been ordered to Farah.

The NATO-led Resolute Support mission in Kabul said U.S. A-10 attack aircraft were also supporting Afghan forces and there had been at least one drone strike, while Afghan air force A-29s and Mi-17 helicopters had conducted multiple attacks.

"Farah city remains under government control, and the Afghan National Defense and Security Forces, supported by U.S. Forces-Afghanistan airpower, are on the offensive against the Taliban," spokesman Lt. Col. Martin O'Donnell said.

However the speed of the attack, which saw large parts of the city including police headquarters and the governor's compound under siege at different times, caused shock among residents.

"The Taliban are moving very fast, if the government does not take serious and speedy action, the province is going to collapse to Taliban," said Hamidullah, a resident of the city reached by telephone in the morning.

Story continues

The attack adds to the problems facing President Ashraf Ghani's government, which has come under increasing public pressure over worsening security ahead of parliamentary elections due in October.

There were no detailed casualty assessments but a Resolute Support spokesman said dozens of Taliban fighters had been killed and there had also been an unspecified number of casualties on the government side.

In one incident, at least 18 soldiers were killed by a suicide bomber in the Askarabad area of the city, Farid Bakhtawar, head of a provincial council said. However, Radmanish said only two soldiers were killed in the blast.

NEW U.S. STRATEGY

Farah province, a remote and sparsely populated area, has seen months of heavy fighting, with hundreds of police and soldiers killed and severe losses inflicted even on elite special forces units. Residents have warned repeatedly that the provincial capital was under threat.

"Farah is in dire need of air support," Dadullah Qane, a provincial council member, said by telephone as the fighting went on in the morning. "The Taliban are well equipped with heavy arms and night vision equipment."

Tuesday's assault adds to the growing number of crisis points around Afghanistan since the Taliban began their annual spring offensive last month, including a series of deadly suicide attacks in the capital, Kabul.

District centers have been lost or threatened in the northern provinces of Baghlan and Badakhshan and there has been heavy fighting in Faryab in the northwest and Ghazni and Zabul, south of Kabul.

Although the insurgents have been unable to take and hold any provincial center, they are active across Afghanistan and the government has firm control over no more than 56 percent of the country, according to U.S. estimates.

The United States has boosted its assistance to the government under a new strategy announced by President Donald Trump last year, sending thousands of additional troops and advisers and stepping up air strikes to support Afghan forces.

Farah, which also borders the opium-rich Taliban heartland of Helmand province, has key smuggling routes into Iran. Hundreds of fighters have moved there as U.S. and Afghan forces have stepped up operations in Helmand.

As the fighting raged on Tuesday, Taliban spokesman Qari Yousuf Ahmadi warned civilians to remain in their houses.

"Mujahideen have nothing to do with civilians, only military positions are the target," he said in a statement, referring to Taliban fighters.

Residents said shops, schools and government offices were closed and the Taliban had set up posts around the city and were checking identity cards and preventing people from fleeing.

(Additional reporting by Qadir Sediqi, Abdul Aziz Ibrahimi, Hamid Shalizi and James Mackenzie in KABUL,Writing by James Mackenzie, Rupam Jain,Editing by Michael Perry, Robert Birsel, William Maclean)