Several weeks after the Ottoman victory at the Second Battle of Gaza, General Friedrich Freiherr Kress von Kressenstein (commander of the victorious 3rd, 16th and 53rd Divisions of the Fourth Army) was reinforced by the 7th and 54th Divisions. Until June 1917, Sheria was the headquarters of the German commanded Ottoman force defending the Gaza-Beersheba line, but as a consequence of EEF aerial bombing, it was moved to Huj in July. This force was reorganised into two corps to hold the Gaza-to-Beersheba line: the XX Corps (16th and 54th Infantry Divisions with the 178th Infantry Regiment and the 3rd Cavalry Division), and the XXII Corps (3rd, 7th, and 53rd Infantry Divisions). By July, the Ottoman force defending the Gaza-to-Beersheba line had increased to 151,742 rifles, 354 machine guns and 330 artillery guns. While the XXII Corps defended Gaza with the 3rd and 53rd Divisions, the XX Corps was headquartered at Huj.