Jammu has historically been the capital of Jammu Province and the winter capital of the east, while Jammu and Kashmir princely state (1846–1952). Jambu Lochan was the brother of Raja Bahu Lochan who constructed a fort, Bahu Fort, on the bank of river Tawi. The city name figures in the ancient book Mahabharata. Excavation near Akhnoor, 32 kilometres (20 mi) from Jammu city, provides evidence that Jammu was once part of the Harappan civilization.
Remains from the Maurya, Kushan, Kushanshahs and Gupta periods have also been found in Jammu. After 480 CE, the area was dominated by the Hephthalites and ruled from Kapisa and Kabul. They were succeeded by the Kushano-Hephthalite dynasty from 565 to 670 CE, then by the Shahi from 670 CE to the early 11th century, when the Shahi were destroyed by the Ghaznavids.
Jammu is also mentioned in accounts of the campaigns of Timur. The area witnessed changes of control following invasions by Mughals and Sikhs, before finally falling under the control of the British.
The Dev Dynasty ruled it for about 984 years from 840 CE to 1816 CE. The city remained in scientific isolation and lagged behind other Indian cities. Then came the Dogra Rule that revived its ancient glory by building great temples, renovated old shrines, built educational institutes and many more. A 43 km long railway line connecting Jammu with Sialkot was laid in 1897 but it was abandoned after the Partition of India as the railway link to Sialkot was broken. Jammu had no rail services until 1971, when the Indian Railways laid the Pathankot – Jammu Tawi Broad Gauge line. The new Jammu Tawi station was opened in 1975. In 2000, much of the old railway station was demolished to make way for an art centre.
After partition of India, Jammu continued to be the winter capital of the state.