In the 2011 Libyan Civil War, after the anti-Gaddafi forces captured Tripoli in August and Sabha in September, Bani Walid, along with Sirte, was one of two final strongholds held by forces loyal to the ousted government of Muammar Gaddafi. There were clashes between anti-Gaddafi forces surrounding the city and Gaddafi loyalists defending it throughout September and early October; the city was finally taken on 17 October.