PESHAWAR, Pakistan — Taliban forces launched a major attack on the Afghan city of Kunduz Saturday, even as peace talks continue with the United States to end America's longest war.

Heavy fighting was ongoing after Taliban fighters mounted attacks from several directions, forcing Afghan security forces to secure reinforcements, Afghan officials said.

They were able to repel the attack in parts of the city, a strategic crossroads about 200 miles north of the capital Kabul, said presidential spokesman Sediq Seddiqi.

The militants had taken hospital patients as hostages, officials said, while electricity and most telephone services were cut and residents were sheltering in their houses.

The "large scale" attack was "progressing smoothly," Taliban spokesman Zabihullah Mujahid claimed in a series of posts on Twitter.

However, Afghan security forces maintained control of the city and were "pounding the enemy" in retaliation with ground and airstrikes, the government's director of police organizational communications Mustafa Kazemi said on Twitter.

"Clearance operation is underway to filter the city of left enemy fighters," he said.

The death toll from the attack was unclear.

ANDSF are pounding the enemy in & around #Kunduz city both from air & ground. Strong joint efforts by our trio forces are underway. We have a 100% ISR, CAS & infantry presence over & within the city. We assure the people that the city will be soon free of enemy fighters. pic.twitter.com/Ssq2y53ZZm — Mustafa Kazemi (@CombatJourno) August 31, 2019

The Taliban now control or hold sway over roughly half of the country and are at their strongest since their 2001 defeat by a U.S.-led invasion.

After 10 months of talks, U.S. presidential envoy Zalmay Khalilzad entered into a ninth round of discussions with Taliban representatives last week in Doha after expressing optimism an accord was close at hand.

Talks continued on Saturday, the Taliban spokesman said.

President Donald Trump said Friday that the U.S. had good negotiations going on with the Islamist group but had not yet reached a deal on U.S. troop withdrawal from Afghanistan.

Trump made the remark to reporters at the White House before leaving for the presidential retreat at Camp David, Maryland.

Trump has made clear he wants to end the U.S. troop presence in Afghanistan, and Secretary of State Mike Pompeo on Monday said he had orders to scale back American forces by the 2020 election.

Some 20,000 U.S. and NATO forces are stationed in Afghanistan training and supporting Afghan forces fighting the Taliban and a local affiliate of the Islamic State group.

Taliban sources have previously told NBC News that they wanted a six-month period to declare a ceasefire upon reaching a deal and wanted the U.S. to pull out all their forces within the same time.

Khalilzad said earlier this month that such a deal wouldn't mean that the United States would no longer come to the aid of the Afghan government's security forces, which the Taliban refuses to recognize as legitimate.

He added that he hopes peace talks begin promptly between the Taliban and the Afghan government once a U.S. agreement is sealed.

Mushtaq Yusufzai reported from Peshawar and Linda Givetash from London.