Dalkeith was granted a charter making it a burgh of barony in 1401 and another to raise it to a burgh of regality in 1540. The settlement of Dalkeith grew south-westwards from its 12th-century castle (now Dalkeith Palace).
Dalkeith has a population of 11,566 people according to the 2001 census.
The town is divided into four distinct areas: Dalkeith proper with its town centre and historic core, with Eskbank to its west and Woodburn to its east. Eskbank is the well-heeled district of Dalkeith with many large Victorian and newer houses.
To the south of Eskbank is Newbattle with its abbey. Woodburn could not be more different, being a working class council estate built from around 1935 onwards. There is an estate called Thornyhall on the edge of Dalkeith near the industrial estate beyond which is the newly-built Dalkeith Campus - housing the high schools of Dalkeith and St David's.
Dalkeith was recently named most thriving town in Midlothian by the Dalkeith Advertiser.
In 1650 Oliver Cromwell’s army came to Dalkeith. His officer, General George Monck, was Commander in Scotland and the government of the country was based out of Dalkeith Castle.
In the 17th century Dalkeith had one of Scotland's largest markets in its exceptionally broad High Street.
In 1831 Dalkeith was linked to Edinburgh by a railway line that transported coal, minerals and agricultural produce and two decades later, in 1853, a Corn Exchange, the largest interior grain market in Scotland, was built.
It was in Dalkeith that William Ewart Gladstone first started his famous "Midlothian Campaign" of 1879. At the election he was returned to Parliament, as member for Midlothian, and became Prime Minister.
'The Collegiate Church of St Nicholas Buccleuch, formerly known as Dalkeith Parish Church, stands on the High Street. Dedicated to St Nicholas, this medieval church became a collegiate establishment in 1406, founded by Sir James Douglas. The nave and transepts date from 1854, when the inside of the church was greatly altered. The chancel was abandoned in 1590, walled off from the rest of the church, and is now ruinous.
James Douglas, 1st Earl of Morton and his wife Joanna, daughter of King James I of Scotland, are buried in the choir and have stone effigies. St Nicholas Buccleuch Church remains one of the two Church of Scotland parish churches in Dalkeith, the other being St John's and King's Park Church.
Dalkeith Palace which replaced the castle in the late 16th century and was rebuilt in the early 18th century, lies at the north-east edge of the town. It is a seat of the Duke of Buccleuch, surrounded by parkland and follies.
The Tollbooth on the High Street began to be used as a tolbooth for the administration of the town in the early 18th century. The plaque above the door reads '1648' but this was taken from another building and does not denote its actual year. The Tollbooth served as a place for law and order and featured a prison in the west half, a court room on the east, and a dungeon known as the ‘black hole’ below ground. In front of the building there is a circle of stones to mark the spot where the last public hanging in Dalkeith occurred in 1827.
Other notable buildings include Watch Towers at the cemetery (1827 and 1829), intended to deter or detect graverobbers, and early 19th-century iron mills.