Morocco annexed the northern two-thirds of Western Sahara ( formerly Spanish Sahara ) in 1976 and claimed the rest of the territory in 1979 , following Mauritania 's withdrawal .