The history of Egypt under the British lasted from 1882, when it was occupied by British forces during the Anglo-Egyptian War, until 1956 after the Suez Crisis, when the last British forces withdrew in accordance with the Anglo-Egyptian agreement of 1954. The first period of British rule (1882–1914) is often called the "veiled protectorate". During this time the Khedivate of Egypt remained an autonomous province of the Ottoman Empire, and the British occupation had no legal basis but constituted a de facto protectorate over the country. Egypt was thus not part of the British Empire. This state of affairs lasted until 1914 when the Ottoman Empire joined World War I on the side of the Central Powers and Britain declared a protectorate over Egypt. The ruling khedive, Abbas II, was deposed and his successor, Hussein Kamel, compelled to declare himself Sultan of Egypt independent of the Ottomans in December 1914. The formal protectorate over Egypt outlasted the war for only a short period. It was brought to an end when the British government issued the Unilateral Declaration of Egyptian Independence on 28 February 1922. Shortly afterwards, Sultan Fuad I declared himself King of Egypt, but the British occupation continued, in accordance with several reserve clauses in the declaration of independence. The situation was normalised in the Anglo-Egyptian treaty of 1936, which granted Britain the right to station troops in Egypt for the defence of the Suez Canal, its link with India. Britain also continued to control the training of the Egyptian Army. During World War II (1939–1945), Egypt came under attack from Italian Libya on account of the British presence there, although Egypt itself remained neutral until late in the war. After the war Egypt sought to modify the treaty, but it was abrogated in its entirety by an anti-British government in October 1951. After the 1952 coup d'état, the British agreed to withdraw their troops, and by June 1956 had done so. Britain went to war against Egypt over the Suez Canal in late 1956, but with insufficient international support was forced to back down. Veiled Protectorate (1882–1913) Throughout the 19th century, the ruling dynasty of Egypt had borrowed and spent vast sums of money on its own luxury and on the infrastructural development of Egypt. The dynasty's economic development was almost wholly oriented toward military dual-use goals. Consequently, despite vast sums of European capital, actual economic production and