After the beginning of the Second World War, Cunningham held a number of short appointments commanding infantry divisions in the United Kingdom Infantry Division, and following its renaming, the 51st before being promoted to lieutenant-general to take command of the East Africa Force in Kenya. During the East African Campaign General Sir Archibald Wavell, the Commander-in-Chief of the British Middle East Command, directed Cunningham to retake British Somaliland and free Addis Ababa, Ethiopia from the Italians whilst forces under the command of Lieutenant-General Sir William Platt would attack from Sudan in the north through Eritrea. Cunningham's offensive started with the occupation of the Indian Ocean ports of Kismayu and Mogadishu, the Italians having retreated into the interior of Somalia. On 6 April 1941, Cunningham's forces entered Addis Ababa. On 11 May the northernmost units of Cunningham's forces, under South African Brigadier Dan Pienaar linked with Platt's forces under Major-General Mosley Mayne to besiege Amba Alagi. On 20 May, Mayne took the surrender of the Italian Army, led by Amedeo di Savoia, 3rd Duke of Aosta, at Amba Alagi. His success in East Africa led to Cunningham's appointment to command the newly formed Eighth Army in North Africa in August 1941. His immediate task was to lead General Sir Claude Auchinleck's Libyan Desert offensive which began on 18 November. However, early losses led Cunningham to recommend the offensive be curtailed. This advice was not accepted by his superiors, and Auchinleck relieved him of his command. He returned to Britain to serve the remainder of the war as Commandant of the Staff College, Camberley and General Officer C-in-C in Northern Ireland and Eastern Command. He was appointed a Knight Commander of the Order of the Bath in 1941.
Post-war
After the war, Cunningham, who was promoted to general on 30 October 1945, returned to the Middle East as High Commissioner of Palestine; he served in the position from 1945 to 1948. As such, he was in charge of operations against the Hagana, the Jewish pre-independence defense army as well as the Etzel and Lehi terrorist gangs who in this period fought against the Mandate authorities and the Palestinian population. Cunningham had retired from the army in October 1946 when he relinquished the role of Commander-in-Chief Palestine but retained the job of High Commissioner until 1948. Asterrorists and Palestinian militias, with Arab armies poised to invade as soon as the British withdrew. The photo of Cunningham taking down the British flag at the port of Haifa is a historical photo often reproduced in Israeli history textbooks. Cunningham served as Colonel Commandant of the Royal Artillery until 1954. Cunningham died in Royal Tunbridge Wells, Kent, England. He is buried with his father and mother under a very simple monument near the Dean Gallery entrance to Dean Cemetery in Edinburgh.