The project aims to restore the palace to its 16th Century heyday
A historian says he has uncovered evidence of Africans being present at Stirling Castle as early as the 1540s.
John Harrison found references to morys - or moors - in the "Bread Book", a record of who received loaves from the royal kitchens in 1549.
The book may be the first clear record of Africans at Stirling Castle's Royal Palace, Mr Harrison said.
The research is part of Historic Scotland's £12m restoration of the palace to its mid-16th Century heyday.
The Bread Book dates from when the palace was the main residence of Scotland's queen mother, and future regent, Mary de Guise, the mother of Mary Queen of Scots.
Mr Harrison believes the "morys" were probably either black Africans or Arabs originating from north Africa.
He said the book provided a "fascinating glimpse" into the diversity of the royal court at Stirling.
"It was quite cosmopolitan at the time, with the French Mary de Guise at its head, and surrounded not just by Scots but by people from Spain, the Rhineland and what is now Belgium," he said.
"Just who the Moors were, and what they were doing, is difficult to say. They were quite low in the court hierarchy, but were part of the household and getting bread at royal expense."
Earlier references to Africans in Scotland exist, but Mr Harrison said these were often uncertain.
He said the importance of the Bread Book was its clarity at a time when record-keeping was relatively thin.
The research has been published in a paper by the Scottish Records Association.
Historic Scotland aim to return the royal palace to how it might have looked in the mid-16th Century.
The organisation wants to gather as much information as possible about court life at the time.
Historic Scotland's Peter Yeoman said: "When the palace opens to the public in 2011 there will be costumed interpreters to tell them about the people and events in each of the rooms.
"Research like this allows us to recapture exactly what was going on and give them a sense of life in the 1540s."