The first mention of it was after 2000 BC, again, before Judaism existed, in an Egyptian text.

So I think we may conclude that the City of Shalem the god of dusk was probably the capital of a lot of peoples long before there was any religion called Judaism.

Roughly 1500-1200 BC, Jerusalem was ruled from Memphis in Egypt by the pharaohs, but the Canaanites remained their proxies.

Petty Canaanite kings continued to dominate the region after Egyptian control lapsed. Some of them over time gradually adopted practices later associated with Judaism, but many other streams of Canaanite belief remained. Probably there were petty tribal chieftains named David and Solomon after 1000 BC, but Jerusalem appears not to have been populated 1000 to 900 BC. and so they didn’t have a palace there.

Whatever the character of the various Canaanite tribal confederations in Palestine, including the proto-Israeli, in 900-770 BC, in the latter year the region fell to the Assyrians.

In 597 BC the Babylonians conquered Palestine and later transported at least some of its population to Babylon. Likely it was there that the Jewish religion became fully elaborated.

In 539 BC, Babylon falls to the Iranian Achaemenid Empire, which emancipates the Jews. The Achaemenids rule most of the civilized world, from Egypt to what is now Pakistan. Palestine is ruled by Iran for nearly 200 years, until 330, when Alexander defeats the Achaemenids.

The Greek Ptolemaic dynasty held sway over Palestine until 198 BC, when the Seleucids conquered it.

In 168 the Maccabean Revolt established a small Jewish state in the area. Aside from the Israeli clans of the pre-Assyrian period, this was the only premodern Jewish state to have Jerusalem as a capital. Even so, they were vassals from 40 BC to the Iranian Parthian empire. Herod became a vassal of the Romans in Palestine in 6 of the Common Era (AD).

Jerusalem was Roman/ Byzantine until 614 CE, when the Iranian Sasanid Empire again conquered it.

In 629 the Byzantines took it back.

The Muslims conquered Jerusalem in 638 and ruled it until 1099, when the Crusaders conquered it it. The Crusaders killed or expelled Jews and Muslims from the city.

The Muslims under Saladin took it back in 1187 CE and allowed Jews to return.

So I think probably Jerusalem was the capital of, like, the Crusader Kingdom of Jerusalem. for several decades.

Muslims then ruled it until the end of World War I, or altogether over a millennium.

So Iran ruled Jerusalem altogether for some 250 years, and the Crusaders for about 200 years, and it was the capital of lots of peoples, including Canaanite kingdoms and the Latin Kingdom of Jerusalem. It was also often a provincial capital under Muslim empires.

In the Sykes-Picot agreement between France and Britain during WW I, which shaped the Middle East, Jerusalem was awarded to Russia.

Lenin was outraged when he found the agreement in the Romanov palace after the 1917 October Revolution, and he had it published. He withdrew Russia from the war and forewent the prize of Jerusalem.

The city was awarded the British by the Versailles Peace Conference, as part of the British Mandate of Palestine.

In the 1947 UN General Assembly partition plan for Palestine, Jerusalem was designated a “Separate Body” to be administered internationally. It was not awarded to Israel by the UN. Although propagandists for Israel are always going on about how they accepted the UN partition plan, they did not, of course. They conquered a lot of territory that the GA did not award them, including West Jerusalem.

It was Jewish settlers in British Mandate Palestine who used violence to grab part of the city, disregarding international law and agreements. The city was mostly populated by Palestinians in any case, what with being a Palestinian city and all.

In 1967 the Israeli army took East Jerusalem, and ever since has squeezed the Palestinian population, driven them into poverty, usurped their property, and surrounded them by squatter settlements. There is no warrant in any part of any international agreement or law for the Israelis to behave this way toward the people who inhabited Jerusalem for over a millennium (and who are in any case almost certainly descendents of Palestinian Jews who converted to Islam). Violence is still a big part of the way Israel rules East Jerusalem, so Netanyahu warning of Muslim violence is rich.

Muslims consider Jerusalem the third holiest city of Islam. Despite Westerners constantly telling them they have no right to do that, they seem pretty attached to the doctrine. There are 1.5 billion of them, and their nerves are raw after centuries of Western colonialism during which they were told their religion was useless and backward. The occupation of Jerusalem was given by al-Qaeda as one reason for its attacks on New York and Washington, D.C. The insistence of Jewish extremists on angering the Muslim world by invading the Aqsa mosque from time to time, and threatening to demolish it, is like those old Warner Bros. cartoons where the foolish little boy keeps teasing a tiger in its cage.