Dunbar is a former royal burgh and gave its name to an ecclesiastical and civil parish. The parish extends around 71⁄2 miles (12.1 km) east to west and is 31⁄2 miles (5.6 km) deep at greatest extent, or 111⁄4 square miles (29 km2), and contains the villages of West Barns, Belhaven, East Barns (abandoned) and several hamlets and farms.

Its strategic position gave rise to a history full of incident and strife but Dunbar has become a quiet dormitory town popular with workers in nearby Edinburgh, who find it an affordable alternative to the capital itself. Until the 1960s the population of the town was little more than 3,500.

In its present form, the name Dunbar is derived from its Gaelic[specify] equivalent (modern Scottish Gaelic: Dùn Barra), meaning "summit fort". That itself is probably a Gaelicisation of the Cumbric form din-bar, with the same meaning. This form seems to be attested as Dynbaer the seventh-century Vita Sancti Wilfredi.[3]

To the north of the present High Street an area of open ground called Castle Park preserves almost exactly the hidden perimeter of an iron agepromontory fort. The early settlement was a principal centre of the people known to the Romans as Votadini and it may have grown in importance when the great hillfort of Traprain Law was abandoned at the end of the 5th century AD. Dunbar was subsumed into Anglian Northumbria as that kingdom expanded in the 6th century and is believed to be synonymous with the Dynbaer of Eddius around 680, the first time that it appears in the written record. The influential Northumbrian monk and scholar St. Cuthbert, born around 630, was probably from around Dunbar. While still a boy, and employed as a shepherd, one night he had a vision of the soul of Aidan being carried to heaven by angels and thereupon went to the monastery of Old Melrose and became a monk.

It was then a king's vill and prison to Bishop Wilfrid. As a royal holding of the kings of Northumbria, the economy centred on the collecting of food renders and the administration of the northern (now Scottish) portion of that kingdom. It was the base of a senior royal official, a reeve (later sheriff), and, perhaps, in the 7th century a dynasty of ealdormen or sub-kings who held northern Northumbria against Pictish encroachment.

Danish and Norse attacks on southern Northumbria caused its power to falter and the northern portion became equally open to annexation by Scotland. Dunbar was burnt by Kenneth MacAlpin in the 9th century. Scottish control was consolidated in the next century and when Lothian was ceded to Malcolm II after the battle of Carham in 1018, Dunbar was finally an acknowledged part of Scotland.

Throughout these turbulent centuries Dunbar’s status must have been preserved because it next features as part of a major land grant and settlement by Malcolm III in favour of the exiled earl Gospatric of Northumbria (to whom he may have been full cousin) during 1072. Malcolm needed to fill a power vacuum on his south-eastern flank; Gospatric required a base from which to plot the resumption of his Northumbrian holding. The grant included Dunbar and, it can be deduced, an extensive swath of East Lothian and Berwickshire or Merse (hence March). Gospatric founded the family of Dunbar. The head of the House of Dunbar filled the position of Earls of Dunbar and March until the 15th century.

The town became successively a baronial burgh and royal burgh (1370) and grew slowly under the shadow of the great Castle of the earls. Scotland and England contended often for possession of the castle and town. The former was 'impregnable' and withstood many sieges; the latter was burnt, frequently. The castle had been slighted (deliberately ruined) in 1568 but the town flourished as an agricultural centre and fishing port despite tempestuous times in the 17th and early 18th centuries. Major battles were fought nearby in 1296 and 1650. The second Battle of Dunbar (1650) was fought during the Wars of the Three Kingdoms between a Scottish Covenanter army and English Parliamentarians led by Oliver Cromwell. The Scots were routed, leading to the overthrow of the monarchy and the occupation of Scotland.

Dunbar gained a reputation as a seaside holiday and golfing resort in the 19th century, the 'bright and breezy burgh' famous for its 'bracing air'.

Since 1983, the town has played host to the first outdoor Pipe Band competition of the season in Scotland. The competition, now held at Hallhill Sports Centre on the second Saturday in May, attracts in the region of 70–80 entries from bands across Scotland and over 2000 visitors for the day. The local band, Dunbar Royal British Legion Pipe Band, has competed with considerable success over the years.

On Saturday 3 January 1987, a devastating fire destroyed much of the town's historic parish church. The church, as it was before the fire, was opened in 1821 and contained a monument to the Earl of Dunbar (1611) which was said to be unequalled throughout Scotland for its Italian craftsmanship in marble. Though the fire practically destroyed the monument and left only the outer walls remaining, the church has since been rebuilt with a modern interior.

Chapel tower (with doocot conversion) of the Trinitarian Priory, Friarscroft, west of the town. Founded c.1240 by Christiana de Brus, Countess of Dunbar.

Dunbar Castle, possibly from the 14th century, rebuilt and remodelled c.1490 and c.1520. Largely ruined with the aid of gunpowder (deliberately by Act of Parliament) in 1567 and with the whole north end removed with the aid of explosives (detonated using a specially-invented electrical system) for the new Victoria Harbour 1842–44.

Parish Church Hall (1910), located behind the post office off the High Street, contains stained glass removed from St Giles' Cathedral, Edinburgh, redundant there on the creation of the Thistle Chapel.[6]

During 2003, archaeological excavations at Oxwell Mains (Lafarge Cement Works) near Dunbar revealed the site of a Mesolithic house believed to be from around the 9th millennium BC. The site suggests a domed building. Although considered extremely rare and a site of national importance this site is in the middle of an area planned for quarrying.

An archaeological excavation undertaken by Headland Archaeology[7] on a site previously occupied by the Captain's Cabin (a local landmark) within the area of Castle Park identified a sequence of archaeological features reflecting around 2,000 years of human activity. The earliest feature was a large ditch which may have formed part of the defences around a promontory fort previously identified during earlier excavations near the coast at Castle Park.[8] The scale of the ditches indicated an impressive monument. A radiocarbon date of between 50 BC and AD 70 was obtained from charcoal recovered from its infill.

Much later a rectangular building was built over the top of the infilled ditch. Large quantities of burnt grain were recovered indicating that the building was a grain store that had been destroyed by fire. It was established that this was part of the Anglian settlement that had also been identified during earlier excavations.

Between the 9th and 11th centuries the area was used as a cemetery.[9] 76 articulated skeletons and the disarticulated remains of a further 51 individuals were recovered. The articulated skeletons were all buried in the standard Christian fashion. A small number of the skeletons were in long cists but the majority were simple shroud burials.

A dump or midden above the cemetery contained many elephant ivory off-cuts dating to the 18th or 19th centuries.

As with the rest of Scotland, Dunbar experiences a maritime climate with cool summers and mild winters. The local climate is notable in that it is one of the few places in Scotland to exceed 1,500 hours of sunshine annually. It is also the driest part of Scotland. Recorded temperature extremes range from 31.0 °C (87.8 °F) during August 1990,[10] down to −12.0 °C (10.4 °F) in January 1982.[11]

Due to its geographical location, Dunbar receives less rain and more hours of direct sunshine per year than anywhere else in Scotland (according to the Met Office). The town has begun to be referred to by locals as 'Sunny Dunny', after a local radio host popularised the term.

Dunbar has two promenades (forming part of the John Muir Way). These provide an ideal viewpoint to see Dunbar's interesting geological features: including volcanic deposits and dykes; seen from a high vantage point on the western, clifftop promenade, which passes the town's Public and Winterfield parks. Looking down onto a raised shore platform, and the raised beaches, further along the coast, one can get an appreciation of the glacial-isostatic uplift that has occurred in this part of Scotland.

Agriculture remains important, but fishing has declined. Its main manufactures are cement at Tarmac's Dunbar Cement Plant at Oxwell Mains (the only integrated cement plant in Scotland) and the Scottish Ales of Belhaven Brewery. Another large local employer is Torness Nuclear Power Station. A large portion of the workforce now commute to Edinburgh or further afield.

Thistly Cross Cider[14] is the only certified cider producer in Scotland.[15] The small company, which started trading in autumn 2008, has been awarded in the UK[16] and exports to several countries.[17]

Dunbar is the birthplace of the explorer, naturalist and conservationist John Muir. The house in which Muir was born is located on the High Street, and has been converted into a museum. There is also a commemorative statue beside the town clock, and John Muir Country Park is located to the northwest of the town. The eastern section of the John Muir Way coastal path starts from the harbour. Other notable residents include singer/songwriter Alex Cornish.

Each year on the last full weekend in September, Dunbar holds a traditional music festival sponsored by various local companies.

Planning Permission and construction for over two years on the outskirts at the Spott Roundabout site (A1) has given the town an Asda supermarket and petrol station (the first in East Lothian). The store is accompanied by a drive-through McDonalds, a restaurant owned by Marston's named the Pine Marten, a hotel also owned by Marston's and a Garden Centre.[18][19] ASDA is proposing to help local businesses and charities in the town as part of its commitment.[20]

Although this will be guaranteed to boost the retail facilities and catchment area of Dunbar, attracting people from Berwick and Haddington to come, there is a fear it might bring congestion to the site and will lead to the decline of the present town centre shops especially the Co-op.[21][22]

Dunbar is also home to the Dunbar United Colts Football Club who play their home matches at Hallhill Sports Centre. The club is open to boys and girls and has around 400 members from 4 years old who play at the Soccer School sessions, right up to adults (Dunbar Athletic) who play in the amateur league. The popular Colts Festival takes place on the second Saturday of Dunbar Civic Week in June of each year. Home colours are black and white stripes. Away colour is blue. Football has been enjoyed by Dunbar youngsters as long ago as the 1920s. During the 1960s the first youth team was formed as Belhaven Boys Club. Training back then took place in the old Belhaven church hall on Beveridge Row. Over the decades training has taken place in a number of locations such as Winterfield and Deer Park. In 1992 the club was renamed Dunbar United Colts Football Club. In September 2001 The Colts moved to their new home at the newly built Hallhill Healthy Living Centre, now known as Hallhill Sports Centre. The Colts are affiliated to the Scottish Youth Football Association and through hard work and dedication are in receipt of the SYFA Community Award. Dunbar United Colts Football Club is run entirely by volunteers.

Dunbar Golf Club: Laid out in 1857 and redesigned by Old Tom Morris around 1894, Dunbar East Links is situated on the estuary of the Firth of Forth. It is used as an Open Championship Qualifying Venue when the Open is played at Muirfield and all of the major Scottish Championships have been played here, The Scottish Amateur, Scottish Professional Championships, and Scottish Boys’ Championship. The British Ladies and the Ladies Home Internationals have also enjoyed Dunbar as a venue. Dunbar is also home to Winterfield Golf Club.

Dunbar Grammar School hosts basketball training for many school and club squads. School teams often participate in the Scottish Cup competition for their appropriate level. The school also hosts training for the club Dunbar Dragons.

The town itself is served by two state primary schools, West Barns[23] and Dunbar,[24] and a state secondary school, Dunbar Grammar School.[25] Dunbar Grammar also serves a wide catchment area which includes the surrounding areas and villages. The school currently has 713 pupils. As of 2004, Paul Raffaeli is the school's current headmaster, following Don Ledingham. Dunbar Primary School has two campuses, the older built John Muir Campus taking Primary 1-3s along with nursery pupils, with the newer Lochend Campus taking Primary 4-7s

Many youth groups use the facilities of The Bleachingfield Community Centre. There is a Youth Club which runs Mondays, Tuesdays and Thursdays (term time) between 18:30 to 20:00 for primary 4 to 7 children and 20:00 to 22:00 for young people at Secondary School. The Youth Cafe is held on Wednesday and Saturday evenings. The centre is also used by a Playgroup, an after school Club and a line dancing club.

Within Dunbar there is a strong interest in science among many parents, no less within the Science Sub-Committee of the Dunbar Primary School Parent Council who are committed to promoting an interest in science and engineering amongst young people. Two initiatives arising from this are Dunbar Scifest, the annual science festival for families, and Dunbar Science Club, a monthly club for youngsters.

This is an annual festival held in Dunbar which aims to generate an interest in science and engineering through a varied programme of events including demonstrations, films and activities. The festival attracts event providers from industry, universities, national organisations and offers the chance for youngsters to engage with career scientists with the hope that they will be inspired to learn more about science, or to follow a scientific career path themselves.

The festival has been running since 2011 and growing in size since then. The long term objective is to grow Dunbar SciFest into a significant annual festival that will ensure that Dunbar becomes a major Scottish focus for public engagement with science. It is well on the way to achieving this having won the National Science and Engineering Week Best Community Event 2012 award.

^Moloney, C. (2001). "New evidence for the origins and evolution of Dunbar; excavations at the Captain's Cabin, Castle Park, Dunbar, East Lothian". Proceedings of the Society of Antiquaries in Scotland. 131: 283–318.