Direct proof of use
The M777 is directly documented in the 2001 War in Afghanistan through U.S. military media and Marine Corps reporting. A Department of Defense video page published on January 28, 2019 identifies soldiers from 2nd Battalion, 12th Field Artillery Regiment training on M777 howitzers while deployed to Camp Dahlke in eastern Afghanistan, where the unit provided artillery fire for U.S. and Afghan forces.
Marine Corps reporting also places M777 howitzers in Helmand province. In October 2011, Charlie Battery, 1st Battalion, 12th Marine Regiment at Fire Base Fiddlers Green was described as living beside its M777 howitzers so it could answer fire-support calls quickly. A December 2011 II Marine Expeditionary Force article says Firebase Saenz had housed Marine artillery units with M777 Lightweight Howitzer cannons that provided indirect fire support for coalition ground forces in northern Helmand.
Sources: Video: Things That Go Boom!, A different fight in Helmand at Fiddlers Green, Combat engineers tear down patrol bases throughout Helmand province
Dated use and precision-fire milestone
The Afghanistan record includes both routine base fire support and a documented precision-artillery milestone. Raytheon reported on June 11, 2012 that the U.S. Marine Corps fired two Excalibur 155 mm precision-guided projectiles in theater at a range of 36 kilometers. The same release says those shots were the longest-distance combat firings of Excalibur since the projectile was fielded in 2007.
A 2012 Defense Media Network interview with Marine Corps towed-artillery program leadership tied that event to a Marine Corps M777 at Forward Operating Base Zeebrugge firing an M982 Excalibur round in February 2012 against insurgents in Kajaki, Musa Qala district. That secondary source adds the M777-specific platform detail absent from Raytheon's short release.
Sources: US Marines fire Excalibur from record range in Afghanistan, Project Manager Towed Artillery Systems Gains an Expanded Portfolio
Operational role
In Afghanistan, the M777's documented role was coalition indirect fire support from fixed or forward artillery positions. The sources identify U.S. soldiers and Marines as users and connect the howitzer to support for U.S., Afghan, and coalition ground forces rather than Afghan-government ownership or Taliban use.
The Helmand reporting shows the weapon used to support coalition forces operating near Marine bases and during the drawdown period. In August 2014, I Marine Expeditionary Force described three M777 howitzers at Camp Bastion as ready for fire missions and safeguarding remaining U.S. and coalition forces while advisers worked with Afghan security forces at Camp Shorabak.
Sources: Sacramento Marine keeps artillery unit primed during Afghan drawdown, A different fight in Helmand at Fiddlers Green, Video: Things That Go Boom!