Korean records say the Silla kingdom began in 57 BCE, when six small villages around Gyeongju joined under a ruler named Bak Hyeokgose. The city went by several names, among them Seorabeol, probably meaning "capital", and Gyerim, meaning rooster forest. A patch of old woodland called Gyerim still stands between the observatory and the National Museum, and some of its trees are more than 2,000 years old.
Silla took the whole peninsula up to the Taedong River in 668, and Gyeongju became the centre of Korean political and cultural life. The court and most of the elite lived here, and its wealth was reported as far away as Persia. Records give 178,936 households at the peak. Buddhism, adopted in the seventh century, filled the surrounding hills with temples, and Queen Seondeok's observatory dates from 634. Many of the best-known sites date from this period.
The fall was quick. Silla broke apart in the late ninth century, a rival kingdom pillaged Gyeongju in 927, and in 935 the last king handed his country to the Goryeo founder, Taejo. The capital moved to Kaesong. Goryeo gave the city its present name in 940 and briefly called it the Eastern Capital, from 987 to 1012. In 1238 Mongol forces destroyed the nine-story wooden pagoda at Hwangnyongsa, and today only the site is left.
Under the Joseon dynasty the city slid further. The Great Yeongnam Road, which linked Seoul to Busan, ran nowhere near it, and in 1601 the provincial capital moved to Daegu. Japanese forces burned the timber buildings of Bulguksa during the Imjin War. Early Joseon Confucian zealots damaged the Buddhas on Namsan. Through all of it, Wikivoyage notes, Gyeongju kept its urban identity.
In the early twentieth century the city was a rural district, and archaeologists began opening the tombs. In 1915 a first museum opened to display what came out, the ancestor of today's National Museum. Most of those digs were led by Japanese archaeologists, and critics call them reckless and extractive. Few excavation reports were ever published. Railways followed: the Donghae Nambu Line, finished in 1935, cut straight through the historic centre, and the Jungang Line in 1942 tied the town to Seoul.
The Korean War mostly passed Gyeongju by, though for a short time in late 1950 parts of the city lay on the front line. Industry arrived in the 1970s: the Seoul to Busan expressway opened through the city in 1971 and the POSCO steel mill started up in neighbouring Pohang in 1973. Mayors were appointed by the central government until 1995, when the city and the surrounding county were merged and the first elected mayor took office. A magnitude 5.8 earthquake hit in September 2015 with no major damage reported. In 2021 archaeologists announced human sacrifices from the Silla era found at the western wall of Wolseong, the old palace site.