By Feroz Sultani and Folad Hamdard

KUNDUZ, Afghanistan (Reuters) - Taliban fighters on Monday battled their way into the center of Kunduz, a city in northern Afghanistan, and seized the provincial governor's office in one of the militant group's biggest territorial gains in 14 years, witnesses and officials said.

In a major setback for Afghan forces, who abandoned a provincial headquarters for the first time since 2001, the insurgents raised their white banner over the central square and freed hundreds of fellow militants from the local jail.

The stunning assault came a day before President Ashraf Ghani's unity government marks its first anniversary, and will further complicate efforts to resume stalled peace negotiations.

It was the second time this year that the hardline Islamist movement has besieged Kunduz, a city defended by Afghan forces battling largely without NATO's support after it withdrew most of its troops last year.

The insurgents launched a surprise, three-pronged offensive before dawn, and by evening had captured the governor's compound and provincial police headquarters, said Zabihullah Mujahid, spokesman for the hardline Islamist movement.

"Our fighters are now advancing toward the airport," Mujahid said on Twitter.

Afghan Interior Ministry spokesman Sediq Sediqqi later confirmed that "most of Kunduz city has fallen to the Taliban," and said Afghan forces were regrouping at the airport.

"IT LOOKS GRIM"

The Kunduz assault marks a troubling development in the insurgency, although government forces have managed to drive the Taliban back from most of the territory gained this year during an escalation in violence.

"It is certainly the first major breach of a provincial capital since 2001," said Graeme Smith, senior analyst for International Crisis Group. "They are choking the Afghan forces from all sides. It looks pretty grim."

The United Nations Assistance Mission in Afghanistan evacuated its Kunduz compound early on Monday, soon after the assault began.

Story continues

"They've been relocated within Afghanistan," said U.N. spokesman Dominic Medley, declining to say where or how many staff were evacuated.

The Afghan army's deputy chief of staff, Murad Ali Murad, defended the security forces' performance, suggesting they withdrew to avoid harming civilians with all-out urban warfare.

"There were enough troops inside Kunduz city, but the insurgents used some route deemed not that sensitive," Murad told a news briefing late on Monday.

"Our forces arrived there on time, but we had to take extra care not to cause civilian casualties."

Dozens of Afghan special forces were flown to Kunduz airport on a C-130 aircraft and were preparing to launch a counter-attack, according to a senior official in Kabul.

The U.S. military did not carry out any airstrikes in support of Afghan forces in Kunduz, U.S. officials said. The officials, who spoke on condition of anonymity, could not say whether any action by the U.S.-led coalition - now primarily in an advise and assist role - was in the works.

U.S. State Department spokeswoman Katy Bondy said that Afghan forces assumed primarily security responsibilities earlier this year, "and we expected that fighting would be severe this year."

"The situation remains fluid, and we are continuing to follow the situation closely," she said.

Abdullah Danishy, deputy governor of Kunduz, vowed that Afghan forces would retake the occupied city.

"We have reinforcements coming from other areas and will beat back the Taliban," Danishy said by telephone from Kunduz airport after fleeing his office.

But with most of downtown Kunduz now in Taliban hands and terrified civilians either trying to flee or hiding inside their homes, the insurgents may be tough to dislodge.

"Once they get inside an urban area, your air assets and artillery become much less useful," Smith said.

FAMILIES SEPARATED

The Taliban were ousted in 2001 after a U.S.-led campaign, and have been fighting to reimpose their rule in sporadic clashes ever since. They have stepped up their offensive this year as NATO forces drew down to just a few thousand troops.

One Reuters witness saw buildings on fire in the south of the city and Taliban fighters entering a 200-bed government-run hospital.

Dozens of panicked residents fled to the city's main airport, but were turned away by security forces. Electricity and phone services were cut across most of the city, and family members struggled to locate one another in the chaos.

"My uncle's wife has been killed by the Taliban today and still my wife and kids are in the area that the Taliban captured, so it is important to free my family," said Matin Safraz, an official at the Interior Ministry who was visiting Kunduz for the Muslim holiday of Eid.

Safraz had retreated to the airport, and said he was prepared to fight the Taliban with a borrowed AK-47 rifle.

Sayed Sarwar Hussaini, a spokesman for Kunduz police, said 20 Taliban fighters had been killed and three Afghan police wounded in the early morning clashes. Updated casualty figures were not immediately available.

According to two security officials, Taliban gunmen, some armed with rocket-propelled grenades, overwhelmed security guards and broke into the main city prison, freeing hundreds of fighters.

Taliban spokesman Mujahid urged Kunduz residents to stay inside.

"The mujahideen are trying to avoid any harm to Kunduz residents," he said on his official Twitter account, referring to Taliban fighters.

The once-quiet north of Afghanistan has seen escalating violence. Kunduz city was the center of fierce fighting earlier this year as the Taliban sought to gain territory after the end of NATO's combat mission at the end of 2014.

A scaled-down NATO presence now mostly trains and advises Afghan forces, although U.S. drones still target militant leaders and a U.S. counter-terrorist force also operates in the country.

(Additional reporting by Mirwais Harooni, Jessica Donati, Hamid Shalizi, and Phil Stewart and Lesley Wroughton in Washington.; Writing by Kay Johnson; editing by Mike Collett-White, Nick Macfie, Robert Birsel and G Crosse)