KABUL, Afghanistan — Taliban insurgents abandoned their effort to take over the capital of the western Afghan province of Farah, leaving the city early Wednesday without apparent opposition, local residents said.

Even with 25 members of the security forces and five civilians killed, officials immediately hailed the insurgents’ departure as a victory. They said that hundreds of insurgents had been killed in the one-day assault on Farah city and that the government’s response proved it could beat back any Taliban initiative to take and hold territory.

But for many Afghans, especially residents in battered Farah, the assault showed mostly that the insurgents could attack at will even against a well-entrenched government position backed up by both Afghan and American air power.

“The Taliban managed to leave the city without a single shot being fired, and the night was calm,” said Abdullah Khan, a resident reached by telephone. “It shows the utmost incompetence of our forces. The Taliban were wandering the Farah city streets openly without fear as if they had lived there a long time, making jokes with their friends and telling citizens to stay calm and not worry.”