Annexation of Western Sahara
The annexation of Western Sahara occurred in two stages: 1976 and 1979. Shortly after Spain gave up control over Spanish Sahara in 1975, both Mauritania and Morocco occupied the territory. On 14 April 1976, the two countries annexed it between themselves via the Western Sahara partition agreement. However, on 14 August 1979, Mauritania renounced all territorial claims to Western Sahara and withdrew its troops, prompting Morocco to extend its annexation to formerly Mauritanian-controlled areas.

Since World War II, it has been held in international law that any act of annexation is illegal. Likewise, the United Nations regards the Moroccan annexation of Western Sahara as null and void, such that the territory is not a legal part of Morocco and it remains subject to the international guidelines for a military occupation.

As Morocco and the United States have had a close relationship since the latter's independence, Morocco has enjoyed full American support throughout the Western Sahara conflict. In exchange for the Israel–Morocco normalization agreement in 2020, the United States officially recognized Western Sahara as part of Morocco, and urged the Sahrawi Arab Democratic Republic to "negotiate a mutually acceptable solution" using Morocco's Western Sahara Autonomy Proposal as the only framework. In 2023, Israel formally recognized Moroccan sovereignty over Western Sahara.

Background
As Spain began the process of decolonization of Western Sahara, a number of international bodies were asked to opine on the territories' status. The UN visiting mission to Spanish Sahara, carried out in May 1975, published their report on 15 October 1975. On the next day, on 16 October 1975, the International Court of Justice Advisory Opinion on Western Sahara was published. Both reports supported a referendum of the people of Western Sahara; the ICJ report acknowledged that Western Sahara had historical links with Morocco and Mauritania, but not sufficient to prove the sovereignty of either State over the territory at the time of the Spanish colonization. The population of the territory thus possessed the right of self-determination.

1975: start of the occupation
On 31 October 1975, Moroccan troops began an invasion of Western Sahara from the north.

The Moroccan government’s Green March took place on 6 November 1975, in which 350,000 unarmed Moroccans converged on the city of Tarfaya in southern Morocco and waited for a signal from King Hassan II of Morocco to cross the border in a peaceful march. 

The Madrid Accords were signed by Spain with Morocco and Mauritania on 14 November 1975.

The Moroccan and Mauritanian annexations were resisted by the Polisario Front, primarily by guerrilla warfare, which had gained backing from Algeria.

1976: annexation and partition
Following the occupation, on 14 April 1976, the Western Sahara partition agreement was signed to formalize the annexation and agree the borders between Morocco and Mauritania. Morocco annexed the northern two-thirds of Western Sahara as its Southern Provinces, and Mauritania annexed the southern third as Tiris al-Gharbiyya.

1979: Mauritanian withdrawal and Morocco further annexation
In 1979, Mauritania withdrew due to pressure from Polisario, including a bombardment of its capital and other economic targets. 

On 14 August 1979, Morocco extended its control and annexed the rest of the territory.

Similar events 
Armed Conflicts over "non-self-governing territories" in the Name of "Restoration of Inherent Territories".
 Ifni war
 Falkland War

References

Annexation
History of Western Sahara