Advisory opinion on Western Sahara

The International Court of Justice Advisory Opinion on Western Sahara was a 1975 advisory, non-binding opinion by the International Court of Justice (ICJ) of two questions presented to it by the UN General Assembly under Resolution 3292 regarding the disputed territory of Western Sahara (then Spanish Sahara). Morocco had approached the UN to adjudicate its and Mauritania’s claims over the territory. 
The ICJ deliberated between 13 December 1974 and 16 October 1976. The final ruling by the Court stated that:
Background.
Morocco gained independence in 1956, and the Istiqlal Party presented its vision for the new state's boundaries. These nationalists appealed to the idea of a Greater Morocco, based upon the territory of the Sharifian empire which preceded French and British colonization. This area included what was at the time Spanish Sahara, French West Africa, and French Algeria. The Moroccan state itself formally adopted the 'Greater Morocco' vision under Mohammed V in 1958. After Mauritanian and Algerian independence in the early 1960s, Morocco released claim to most of Greater Morocco. However, it has maintained its irredentist claim over Western Sahara.
Following the establishment of the Special Committee on Decolonization, the Spanish Sahara was included in 1963 in the preliminary list of territories to which the declaration on the granting of independence to colonial peoples and countries applied, and from that year on the question of Western Sahara had been regularly considered by the Special Committee and in the General Assembly. On 20 December 1966, United Nations General Assembly Resolution 2229 called on Spain to hold a referendum on self-determination in the territory.
After initially resisting all claims by Morocco and Mauritania (which also started laying claims to parts of the region), Spain announced on 20 August 1974 that a referendum on self-determination would be held in the first six months of 1975.
Morocco declared it cannot accept a referendum which would include an option for independence and renewed its demands for the integration of the remaining provinces of Saguia el-Hamra and Rio de Oro to the country's sovereignty . In Mauritania, a smaller movement claimed some of the territory, partitioning it with Morocco .
Algeria–Morocco relations had been strained since Algeria's independence in 1962, culminating in the Sand war, and a lack of normalized relations . Algeria, after initially supporting Morocco and Mauritania in their demands , started in 1975 to support the independence of the territory. Algeria officially supported the right of self-determination of the people of the former Spanish colony, as it had supported the right of self-determination of the peoples of the rest of the African colonized countries. The Polisario Front, created in 1973, engaged in several attacks against Spanish garrisons and patrols, and also attacked the Fosbucraa conveyor belt, which exported the rich local phosphates to the El Marsa port.
On 17 September 1974, King Hassan II announced his intention to bring the issue to the ICJ . In December, Spain agreed to delay the referendum pending the opinion of the court. They gave their support to ICJ submission on the grounds that it be a non-binding, advisory opinion, rather than a "contentious issue", where the ruling would oblige the interested states to act in a particular manner .
On 13 December, the United Nations General Assembly voted on a submission, resulting in UN General Assembly Resolution 3292, affirming it and defining the wording of the questions to be submitted. Algeria was among the nations voting in favor, and several Third World nations abstained.
Submission.
UN General Assembly Resolution 3292 requested that the International Court give an advisory opinion on the following questions:
And, should the majority opinion be "no", the following would be addressed:
In the meantime, Morocco and Mauritania jointly agreed to not contest the issue of partition or sovereignty. On 16 January 1975, Spain officially announced the suspension of the referendum plan, pending the opinion of the court. From 12-19 May, a small investigative team made of citizens from Cuba, Iran, and Côte d'Ivoire was sent into the region to assess public support for independence. They also performed inquiries in Algeria, Mauritania, Morocco, and Spain.
In the summer, the questions were submitted by King Hassan II and Spain. Algeria, Mauritania, Morocco, and Spain were all given permission to present evidence at the hearings (the Polisario was locked out as only internationally recognized states have a right to speak - Algeria largely represented the Sahrawis). Twenty-seven sessions were held in June and July before the Court called the proceedings final.
The arguments presented by Morocco and Mauritania were essentially similar: that either one had a sovereign right over the territory. In the case of Morocco, the kingdom of Morocco claimed the allegiance of a variety of tribes in surrounding territory. In the case of Mauritania, there was no clearly defined state that existed at the time. Instead, Mauritania argued that a similar entity existed which they called "bilad Chinguetti". Spain argued against Moroccan sovereignty, citing the relationship that Spanish explorers and colonizers had established with the sultan, none of which ever recognized his authority over the region. Algeria also defended the position that the Sahrawis were a distinct people, and not under the subjection of Morocco or Mauritania.
The opinion.
On 15 October, a UN visiting mission sent by the General Assembly to tour the region and investigate the political situation published its findings, showing that the Sahrawi population were "overwhelmingly" in favor of independence from both Spain and Morocco/Mauritania. These findings were submitted to the Court, who published their opinion the next day.
For the former question, the Court decided by a vote of 13 to three that the court could make a decision on the matter, and unanimously voted that at the time of colonization (defined as 28 November 1884), the territory was not "terra nullius" (that is, the territory, did belong to someone).
For the latter question, the Court decided by a vote of 14 to two that it would decide. It was of the opinion, by 14 votes to two, that there were legal ties of allegiance between this territory and the Kingdom of Morocco. Furthermore, it was of opinion, by 15 votes to one, that there were legal ties between this territory and the "Mauritanian entity". However, the Court defined the nature of these legal ties in the penultimate paragraph of its opinion, and declared that neither legal tie implied sovereignty or rightful ownership over the territory. These legal ties also did not apply to "self-determination through the free and genuine expression of the will of the peoples of the Territory." (ICJ Reports (1975) p. 68, para. 162)
Results.
The opinion of the Court was interpreted differently by the different parties, and each focused on what it sees as supporting its claims.
While Morocco and Mauritania found in the answers to the two questions a recognition that their claims are legitimate and historically based, Algeria and the Polisario Front focused on the penultimate paragraph that stated that the court's decision was not to hinder the application of self-determination through the ongoing Spanish referendum.
King Hassan II declared the organisation of a peaceful march to force Spain to start negotiations on the status of the territory, to which Spain finally agreed. A round of talks between Spain, Morocco and Mauritania were held in Madrid and culminated in a tripartite agreement, becoming known as the Madrid Accords On 16 November 1975, where Spain formally ceded the administration of the northern two thirds of the territory to Morocco, while the southern third was to be administrated by Mauritania. Algeria protested against the agreement, and president Boumedienne retaliated by expelling all Moroccans living in Algeria. The text of the Madrid Accords have never been made public.
In consequence, the Court's decisions were largely disregarded by the interested parties. On 31 October 1975 the first Moroccan troops invaded Western Sahara from the north-east. Algeria sent its troops into the territory of Western Sahara to help in the logistic of the evacuation of the Sahrawi refugees who have been bombarded by Moroccan air forces, which led to the first and last direct military confrontation between units of the Moroccan armed forces and the Algerian national army in the First Battle of Amgala (1976). The Algerian army suffered hundreds of deaths and more than a hundred soldiers were made prisoners by the Moroccan army. Diplomatic intervention from Saudi Arabia and Egypt prevented the situation from escalating further.
Spain's last soldier left the territory on 26 February 1976 . The next day, the Saharawi Arab Democratic Republic was declared by Polisario Front representatives. Morocco intensified its military presence in the region, and by the end of the year, Mauritania and Morocco had partitioned the territory. Mauritania was too weak militarily and economically to compete against Polisario, though, and was forced to renounce its claims in 1979. Morocco immediately annexed that territory. Morocco has continued to administer most of Western Sahara, and its sovereignty has been recognized by the United States. At the same time, 82 governments have recognized the Sahrawi Republic as the legitimate government of Western Sahara.