A multi-million pound lottery grant has secured for Scotland the most important literary archive to become available in the last 100 years.
The archive contains papers from many great literary names
The National Library of Scotland is to be given £17.7m by the Heritage Lottery Fund to acquire the "unique" John Murray publishing archive.
The grant means it will be open to the public for the first time.
Lottery cash of £16m was also awarded to fund the development of a new Riverside Museum in Glasgow.
However, the acquisition of the archive is seen as the major coup in the grant announcements.
It was started by the first John Murray, who was a Scot and founded his publishing house in London in 1768.
Seven successive Murray generations built up the archive with the close relationships each enjoyed with the writers of their time helping to make it a "who's who" of 19th century society.
Described as one of the world's most significant literary collections, the John Murray Archive is made up of 150,000 manuscripts, papers and letters.
It contains correspondence between the publisher and influential figures including Jane Austen, Charles Darwin, Sir Walter Scott, Benjamin Disraeli, David Livingstone, Thomas Carlyle, Sir Arthur Conan Doyle and Edith Wharton, among others.
It has been independently valued at £45m but has been offered for sale to NLS at a reduced price of £31.2m to keep the collection in the United Kingdom.
The National Librarian, Martyn Wade, said HLF's decision was wonderful news for Scotland and for the library.
"It is fantastic to secure such a unique and important collection for Scotland.
''There is still a lot to do, not least to achieve our own fundraising target of £6.5m, but the HLF grant means that our funding package is now in place.
''It will allow us to go forward to complete the purchase.
"We will now sit down with all interested parties and draw up a timetable for bringing the Archive to Scotland and ensure it is available for everyone to use and enjoy.
''It is entirely fitting that the Archive will be housed in Edinburgh, the first Unesco World City of Literature and there is no doubt that it will enhance Scotland's cultural reputation both at home and overseas.
''This is a great day for the National Library and for Scotland as a whole.
''It is also important that this archive has been saved for the United Kingdom."
A detail from the passport of archaeologist Henry Austin Layard
The collection contains many literary and historical treasures along with political, scientific, engineering, travel and exploration material providing a rich source of information on British life and society over three centuries.
In recent weeks NLS had negotiated an additional £2m reduction in the price with the seller, John Murray, to bring it down to £31.2m.
In addition, the Scottish Executive agreed to find another £1.8m to increase its contribution to £8.3m and NLS put in an additional £500,000.
All of this reduced the amount being requested from HLF to a maximum of £17.7m.