The earliest libraries in Midlothian were private subscription libraries, which meant that anybody who wished to use them had to pay a regular fee to gain access to the books. Penicuik Subscription Library opened in 1797, Loanhead in 1818 and the Dalkeith Scientific Association, which was founded in 1835, had a private library for its members.
Some shops also ran their own borrowing libraries, which people could use for small fee. In Bonnyrigg there was a library in a local café, which was known as the ‘Coffee-House Library’.
In 1853 the Public Libraries Act gave burgh councils the option of running a free public library. These were paid for out of local taxation, which often meant that poorer areas of the country like Midlothian were unable to afford them.
The free public library movement in Scotland was greatly encouraged by the generosity and foresight of Andrew Carnegie.
Carnegie was born in Dunfermline in 1853. He emigrated to the United States where he became a wealthy iron and steel magnate. In his later life, he used his vast fortune to finance many philanthropic projects. He offered money for the building of public libraries on condition that others donated building land and paid for the books and running costs.

The first Carnegie library in the old Midlothian County was opened at West Calder on 24 November 1903. Two years earlier a new public library had been proposed for Dalkeith. After great debate the Burgh Council rejected it because it would impose a heavy burden on local ratepayers.
Bonnyrigg Town Council, however, accepted Carnegie’s offer and land was obtained in Lothian Street. Building work started on 31 July 1908 and a memorial stone was laid by Provost Archibald Gilchrist on 2 September 1908.

Bonnyrigg Public Library was opened on Saturday 2 October 1909 amidst an ‘extraordinary degree’ of interest from ‘hundreds of inhabitants’. A special commemorative poem was written by Provost Porteous of Lasswade, which began:
‘Twas on a lovely autumn afternoon,
A great big day for Bonnyrigg toon;
What a folk did gather there
Fra round about far and near.
For to attend a demonstration
Of Carnegie’s presentation;
A lovely mansion here you’ll find
With beauty and order all combined.
The opening ceremony was performed by Dr Hew Morrison, who represented Andrew Carnegie. He was accompanied by Provost Gilchrist and his wife, and representatives of the Town Council and other bodies in Bonnyrigg. Dr Morrison was presented with a special silver key to open the building, but, as the Dalkeith Advertiser reported, there was a ‘slight contretemps’ when he tried to open the front door:
‘The Doctor inserted and turned the key in the lock, but the door did not respond to the gentle push with which he attempted to open it. Even the combined efforts of the Provost and some other gentlemen in the vicinity failed to open it. Presently however the door swung easily open, the appearance of the caretaker behind indicating the bolt securing the door from inside had been withdrawn. The incident lasted no more than a minute, and its only effect was to cause merriment amongst the spectators.’
Following the opening ceremony there were a long series of speeches in the library hall followed by a reception:
Now when the business it was over
They did adjourn to the corner,
And as some were cauld and shakey
They got cakes and wine and aqua vittie.
The new library was designed by the Edinburgh architectural firm of Greig, Fairbairn and McNiven. It was built in the English ‘medieval style’ style in red sandstone and had many fine details, including the Dundas family coat-of-arms over the main entrance. On the ground floor, the library had a lending section and a reading room with spaces for 36 readers and a separate alcove for women. A side entrance to the building gave access to a meeting room and also to a public bathroom, which had ‘two spray baths, one plunge bath and a changing box’. On the first floor there was a public lecture hall that could hold 200 people. The building included a flat for the librarian and caretaker. The total cost of the library was £2300 of which Andrew Carnegie donated £2000.

The library housed around 6000 books which had been chosen to suit all tastes, including fiction by the latest authors. There was also a selection of ‘Juvenile Literature’ for children, which Provost Gilchrist hoped would ‘shape and mould their minds in the right direction’. The Reference Room included newspapers and magazines.
The Lending Library was open on Mondays, Wednesdays and Fridays between 3 and 5 o’clock in the afternoon and between 7 and 9 o’clock in the evening. The Reference Room was open each day except Sunday between 9am and 10pm. Access was available to every ratepayer in Bonnyrigg but they were only allowed to borrow one book at a time. The library had strict rules about behaviour. Users were not allowed to cut articles out of the newspapers and they were not to be ‘intoxicated, disorderly or uncleanly’. Users were fined one penny for every three days that their books were overdue.

The library was originally run by a Library Committee of Bonnyrigg Town Council but in 1921 Midlothian Education Authority took over the administration of the lending library. Funding was always limited and a billiards room was introduced to supplement income. A Council report in 1945 described the library as ‘a somewhat dingy unprogressive appearance’. Bonnyrigg library was soon incorporated into the new Midlothian County Council Library Scheme.
The current library in Bonnyrigg opened on 16 April 1974 but in 1989 the old library was pressed into service because of building work in the new library.
Since 1909, many other public libraries have been opened in Midlothian and they continue to provide a valuable free service to the local community