The huge rise in popularity of curry among all social classes has seen it emerge as Scotland's other national dish.

Now surprising new evidence shows that it was being enjoyed by the wealthy elite over 200 years ago, as curry powder was being sold by an Edinburgh grocer in 1798.

The grocer, John Caird, informs customers through the Edinburgh Evening Courant that he "has just received a parcel of REAL INDIA CURRY POWDER in the original package." It was selling at 2/6d a canister.

This is just one of the fascinating revelations about Scotland's changing relationship with food over four centuries uncovered in a free exhibition opening today at the National Library of Scotland. A 16th century recipe for marmalade, by the Countess of Sutherland, is also on show for the first time.

Lifting the Lid: 400 years of food and drink in Scotland is being staged during Scotland's Year of Food and Drink. It will help visitors understand more of how their ancestors lived and how their diet links to what we eat today.

The main ingredients for the exhibition come from the rare collection of recipe books, dating from the 17th century to the 1940s, that are held at the National Library. These were mostly written by female members of wealthy families as memory aids to record favourite dishes and new culinary experiences rather than the everyday meals that would be served. They are supported by other striking information in published recipe books, household accounts and inventories, tradesmen's bills, menus, visitors' journals, maps and amateur and government films about food.

Visitors to the exhibition will be able to see what is thought to be Scotland's first ever recipe book - John Reid's The Scots Gard'ner - which was published in 1683. Although principally a book for food growers, it also includes tips for cooks on preparing meals.

The exhibition tells of old Scottish measures such as a chopin (two pints), a mutchkin (just under a pint), a peck (two gallons) and a forpet or lippie (half a gallon).While some foods such as Cullen skink, crannachan and clootie dumpling have lived on, others like powsowdie (a sheep heid's broth), crappit heids (haddock heads and livers) and cruddy butter (a type of cheese) have all but disappeared in the mists of time.

"The written records we have are mostly for the wealthy," said curator Olive Geddes, "but the exhibition also looks at the role of the cook from the ordinary housewife and domestic servant to the professional chef. The social and economic significance of food will also feature. How far has social convention dictated what was eaten by whom and when?"

* Lifting the Lid: 400 years of food and drink in Scotland runs from June 12 to November 8 at the National Library of Scotland, George 1V Bridge, Edinburgh. Entry is free.