All the tribes of Israel come to David at Hebron and tell him they are his bone and flesh. They remind him that even when Saul was king it was David who led Israel out and in, and that the Lord said he would shepherd his people and be their prince. The elders make a covenant with him before the Lord and anoint him king over Israel. David was thirty years old when he began to reign and reigned forty years: seven years and six months at Hebron over Judah, and thirty-three at Jerusalem over all Israel and Judah.
The king and his men march against Jerusalem, inhabited by the Jebusites, who trust that their stronghold is impregnable. David captures the stronghold of Zion, which is called the city of David from then on; he builds around it and grows ever greater, for the Lord, the God of hosts, was with him. Hiram, king of Tyre, sends messengers, cedar timber, carpenters and masons to build him a house. David realizes that the Lord has established him as king over Israel and has exalted his kingdom for the sake of his people. The sons born to him in Jerusalem are listed.
When the Philistines hear that David has been anointed king, they come up to find him and spread out in the valley of Rephaim. David asks the Lord whether to attack, and the Lord says yes. He wins at Baal-perazim, meaning the Lord breaks through, and the Philistines abandon their idols. They return to the valley, and this time the Lord tells him to circle around and attack from behind, opposite the balsam trees, when he hears the sound of marching in the tops of the trees. David obeys and strikes down the Philistines from Geba to Gezer.