According to Youremailverifier, ceramic evidence indicates the occupation of the village of Ophel, within what is now Jerusalem, as early as the Copper Age, around 4000 BC. n. and.,   with evidence of a permanent settlement in the first centuries of the early Bronze Age (c. 3000-2800 BC).
Ann Killebrew proved that Jerusalem was already a walled city in stages MB IIB and IA IIC (between 1800-1550 and between 720-586 BC), during the Late Bronze Age, and ages IA I and IIA / B Jerusalem was a unwalled and relatively insignificant town. 
The earliest writings that refer to the city are those grouped in the Berlin and Brussels Execration Texts (c. 19th century BC) refer to a city called Roshlamem or Rosh-ramen; and in the Amarna Letters (circa 14th century BC) they refer to Urusalem (‘city of peace’).  
Some archaeologists, including Kathleen Kenyon, believe that Jerusalem was a city founded by a Western Semitic people, with settlements organized around the 26th century BC. n. and.  According to a Jewish tradition, Jerusalem was founded by Shem and Eber, ancestors of Abraham. According to the biblical account, Melchizedek (righteous king) was the king of Salem, priest of God and presented bread and wine to Abraham, who was a nomadic Aramaic, and he blessed him and Abraham gave him tithe; Salem is identified with Jerusalem. The Jebusites controlled the city (Jebus) towards the 11th century BC n. and. when David conquered her. Kathleen Kenyon’s discovery of the Jebusite and Davidic walls of ancient Jerusalem,  as well as more recent excavations of the Great Rock structure tend to be interpreted by archaeologists as corroborating biblical texts on the conquest of the Jabusite city. by David. 
Around the year 1004 a. n, the King David of Israel and Judah conquered Jerusalem from the Jebusites by a contingent sent through an underground spring, and became the capital of the unified kingdom. His son Solomon built in a few years the Temple of Jerusalem, destined to contain the Ark of the Covenant and the Laws that Yahweh granted Moses on two stone tablets on Mount Sinai. This would be the only temple that would allow the Hebrew religious law consecrated to the Yahwist cult.Although it seems that another temple existed on Elephantine Island, in the middle course of the Nile River, founded around 650 BC. n. and. by a Jewish community emigrated before the reign of Josiah (640-600 BC).
In the eleventh century a. n. and. the king Jew David conquered the city of Jebus, Jebusites bastion of the town, one of those who inhabited the land of Canaan. The bastion was fortified with solid walls that surrounded it. King David settled there and renamed it Ir David (The City of David). This place is currently located to the southwest of the present Old City and is called Ophel Hill. It was discovered and excavated by the Palestine Exploration Fund between 1923 and 1925.
David’s son Solomon extended the construction of the walls and also built the temple that bore his name. The city was renamed Ir Salomon (Solomon’s City) called in the Bible, Jerusalem. At the death of Solomon around the year 962 a. n. and. a schism occurred in the Jewish people and two states were formed: Israel, with its capital in Samaria and Judah, whose capital was Jerusalem.
After the separation of Israel and Judá in 920 a. n. and. Jerusalem became the capital of the kingdom of Judah. After different vicissitudes in its history, in which it served as the capital of the independent kingdom of Judah, it subsequently experienced different stages of foreign domination, first under the influence of the Assyrians, who subjected the kingdom of Judah to the payment of tribute, and then directly by the Babylonians (590-540 BC) who took the city and razed it, destroying the Temple, in July 587 BC. n. and. ; later it was subjected to the Persians (540-332 BC), the Macedonians (332-312 BC) and by their heirs the Seleucids (312-130 BC). From this moment, under the rule of the Hasmoneans it would know a period of relative independence, although it would be conquered, along with the entire kingdom, by the Roman troops of Pompey in 64 BC. n. and.
The city resisted through the years the attacks of its powerful neighbors, also going through various stages of vassalage until 587 BC. n. and. during the reign of the last king of Judah, Zedekiah, when it was conquered and razed by King Nebuchadnezzar II. The kingdom of Judah became a province of the Babylonian Empire (or Chaldean Empire) and the majority of the Jewish ruling class would be sent into exile in Babylon.
In the year 537 a. n. and. the Persian king Cyrus II the Great conquered the Babylonian Empire and allowed the return of the deported Jewish communities to the province of Judah; They returned to Jerusalem and rebuilt the city and Solomon’s Temple.
In 332 a. n. and. Alexander the Great conquered the Persian Empire and the city did not suffer destruction. Upon the death of Alexander, Judah (or Judea) and Jerusalem became part of the Seleucid Empire, which in turn would be annexed to the Roman Empire in 64 BC. n. and. by the Roman general Cneo Pompeyo Magno, after defeating said Empire. Jerusalem suffered the Roman siege and conquest, with its annexation to the Empire.
The year 21 a. n. and. King Herod the Great restored the city and the Temple, a part called the Wailing Wall still standing, of great importance in the Jewish religion.
The city of Jerusalem was recovered during the mandate of General Marco Vipsanio Agrippa, who ordered the construction of a new wall called the Third Wall, remaining the city under the administration of a religious elite, the Hasmoneans, when a Jewish revolt occurred that again involved the Roman siege of Jerusalem, and the taking and destruction of the city in the year 70 carried out by the Roman general Tito Flavio Vespasiano.
From about the year 33 there was a growing Christian church in Jerusalem, where the so-called Council of Jerusalem was also celebrated around the year 49.
In the year 66 a revolt of the Jews took place that supposed the siege and the taking of the city by the emperor Titus in the year 70, together with the second destruction of the Temple of Jerusalem. Hadrian’s reconstruction project as a completely Roman city (Aelia Capitolina) involved a new revolt of the Jews between 132 and 135 (the Bar Kochba Rebellion), thus beginning the definitive Jewish “diaspora”.
Around the year 135, Emperor Hadrian decided to rebuild the city with the name of Aelia Capitolina, which caused a new revolt among the Jews, which ended in 135 with the Roman victory and the expulsion and exile of most of the Jewish people. known as the Diaspora. The territory of Judea became the Roman province of Syria Palestine or Palestine.
The fate of Jerusalem continued to be linked to successive conquests and conflicts, forming part of the Eastern Roman Empire or Byzantine Empire, within which it was one of the four places of doctrinal religious importance of Christianity, along with Constantinople, Antioch and Alexandria.
In the year 326, the Emperor Constantine I the Great ordered to build the Church of the Holy Sepulcher, which became one of the main religious sites of Christianity.
In 614 the Sassanid Empire conquered the city, ruling it until 638, being displaced by the Muslim expansion that occupied the city, incorporating it into the Umayyad Caliphate of Damascus, the Abbasid Caliphate and the Ottoman Empire successively.
Between the years 687 and 691 the Dome of the Rock was built. In 710 the Al-Aqsa Mosque was completed. Both temples are important religious points of the Muslim religion.
In 1095 Pope Urban II preached at the Council of Clermont (France) the First Crusade, aimed at conquering Jerusalem from the Muslims. The French aristocrat Godofredo de Bouillon achieved this task and after carrying out a massacre he conquered the city and created the Kingdom of Jerusalem, of which his brother Baudouin I was the first representative with the title of “King of Jerusalem.” During the following years, the presence of the Christian military orders was intermittent in the city, alternated with the presence of Muslim troops, among which Saladin stood out, who besieged and definitively conquered the city in 1244.
The walls of Jerusalem were destroyed and rebuilt many times. The current walls were erected in 1538 by the Ottoman Sultan Suleiman the Magnificent and continued under Ottoman rule until the end of the First World War (1914-1918).
The walls have an approximate extension of 4.5 km and their height varies between 5 and 15 m, with a thickness of 3 m. They have 43 watchtowers and 11 gates, of which only 7 are open.