Richard's grandson, Gilbert de Clare, the last male de Clare, died at the Battle of Bannockburn in 1314 and the castle was given to Hugh Despenser the Younger, the controversial favourite of Edward II. Poor harvests and harsh governance by the Despenser family encouraged a Welsh rebellion under Llywelyn Bren in 1316; this was crushed and Llywelyn was hanged, drawn and quartered in Cardiff Castle in 1318 on Hugh's orders. The execution attracted much criticism from across both the English and Welsh communities, and in 1321 Hugh arrested Sir William Fleminge as a scapegoat for the incident, first detaining him in the Black Tower and then executing him in the castle grounds. Conflict between the Despensers and the other Marcher Lords broke out soon after, leading to the castle being sacked in 1321 during the Despenser War. The Despensers recovered the castle and retained it for the rest of the century, despite the execution of Hugh Despenser for treason in 1326. Under a 1340 charter granted by the Despensers, the castle's constable was made the "de facto" mayor of Cardiff, controlling the local courts.