Located in northern Morocco, Tangier was a vital city for the Berbers, whose legend says that the city was built by Sophax, the son of Tinjis, who was married to the giant Berber hero Antaios / Antaeus. Other legends says that Sophax's father was the Greek demi-god Hercules, the son of Zeus, who married Tinjis after he killed Antaeus in a struggle during which Africa from Europe were separated.

Tinjis is the Amazigh (Berber dialect) word for marsh, so it's commonly accepted that it's origin is indeed Berber.

Tangier has had a tumultuous past. In the 7th century BC it was colonised by the Phoenicians, a people originally from actual Lebanon who then had businesses and colonies all over the Mediterranean Sea. Then came the Carthaginians, originally from the important ancient Phoenician colony of Carthago.

In the 5th century BC, it was ruled by the Romans, then free, then again ruled by Augustus. During this period, it was an important city, capital of the Roman territories of North West Africa, the province of Mauretania Tingitania. In 429 AD it was taken by the Vandals, one of the Barbarians tribes that swepted the Roman Empire. About a century later, the city became part of the Byzantine Empire, and eventually fell under Arab rule in 707, who used it as a base for the invasion of Iberian peninsula four years later.

Throughout the 15th century, the Portuguese tried several times to conquer it, after they took nearby Ceuta in 1415, but they didn't succeed. On their first attempt, in 1437, Fernando, son of the Portuguese King Joao fell prisoner and ended up dying in captivity some year later in Fez. Eventually, in 1471 the city was abandoned by its habitants when they understood that the recent conquest of nearby Asilah could be the preparation to another strong assault on Tangier.

Although in several ocasions Portuguese had plans to abandon the city, it was kept by them until 1661, when, along with Bombay in India, it was given to the British as part of Portuguese princess Catarina's dowry on her marriage with King Charles II. The resident Portuguese people abandoned the city soon after the arrival of the British, accusing them of raping and looting.

The British only stayed until 1684, when Moroccan Sultan Moulay Ismail tried to take over and established a blockade that led to a retreat by the British, preceded however, by the destruction of Tangier’s ports and fortresses. Some say that with Moulay Ismail in charge, the city steadily declined, but others say that he rebuilt the city and it maintained its importance as the main port of the region.

By the late 19th century, Europe had developed a commercial interest in Tangier, due to its prime geographical location. In 1905, German Kaiser Wilhelm II spoke in favor of Morocco ’s independence, launching an international crisis. In 1912, Morocco was split between France and Spain, with Tangier as an international zone jointly controlled by France, Spain and Britain. In 1923 Italy, Belgium, Holland, Sweden, United States and Portugal joined the administration of the city. The Soviet Union also also joined in 1945.

When Morocco gained its independence in 1956 it was finally reunited with Tangier.