KABUL, July 12 (Reuters) - The US general leading the war in Afghanistan, Austin Miller, relinquished command on Monday (Jul 12) at a ceremony in Kabul, in what was a symbolic end to America's longest conflict even as Taliban insurgents gain momentum across the country.

Miller, America's last four-star commander to serve on the ground in Afghanistan, stepped down ahead of a formal end to the US military mission there on Aug 31, a date set by President Joe Biden as he looks to extricate the country from the two-decade-old war.

Addressing a small gathering outside his military headquarters in Kabul, Miller vowed to remember the lives lost in the fighting and called on the Taliban to halt a wave of violent attacks that have given them control of more territory than at any time since the conflict began.

"What I tell the Taliban is they're responsible too. The violence that's going on is against the will of the Afghan people, and it needs to stop," Miller said.

While the ceremony may offer some sense of closure for US veterans who served in Afghanistan, it's unclear whether it will succeed in reassuring the Western-backed Afghan government as the Taliban press ground offensives.

US Marine General Kenneth McKenzie, whose Florida-based Central Command oversees US forces in hot-spots including Afghanistan, Iraq and Syria, flew into Kabul to underscore America's future assistance to Afghan security forces.

"You can count on our support in the dangerous and difficult days ahead. We will be with you," McKenzie said in his address.

Speaking separately to a small group of reporters, McKenzie cautioned that the Taliban, in his view, were seeking "a military solution" to a war that the United States has unsuccessfully tried to end with a peace agreement between the Taliban and Afghan President Ashraf Ghani's government.

He said provincial capitals were at risk but noted that the US-backed Afghan security forces "are determined to fight very hard for those provincial capitals."

McKenzie will be able to authorise US air strikes against the Taliban through Aug 31 in support of Ghani's Western-backed government.

But after that, the Marine general said when it came to US strikes in Afghanistan, his focus will shift squarely to counter-terrorism operations against al Qaeda and Islamic State.