The city of Jerusalem has been surrounded by walls for its defense since ancient times. In the Middle Bronze Age, a period also known in biblical terms as the era of the Patriarchs, a city named Jebus was built on the southeastern hill of Jerusalem, relatively small (50,000 square meters) but well fortified. Remains of its walls are located above the Siloam Tunnel.
From my recollection, the first mention in Tanac"h that Jerusalem had a wall is in Melachim (Kings) I 3:1 where it says that Shlomo built the wall of Jerusalem. However, based on above, it seems that the city had a wall for a long period prior to that. Who built the first wall and when?