The National Records of Scotland (NRS) estimated that in mid 2013 there were 5,327,700 people living in the country - a rise of 14,100 from the previous year.
For the tenth year in a row more people came to live in Scotland than left the country to go and live in the rest of the UK or overseas.
Inward migration exceeded outward migration by approximately 9,960 between mid 2012 and mid 2013, according to the figures, which are based on data from the 2011 census.
There were also about 910 more births than deaths over the same period.
NRS chief executive Tim Ellis said: "Scotland's population has continued to grow, reaching its highest-ever level last year.
"Scotland's population increased by 14,100 from mid-2012 to mid-2013 primarily because of a net in-flow of approximately 10,000 more people coming to Scotland than leaving, although there were also around 900 more births than deaths.
"For the tenth consecutive year more people arrived in Scotland from the rest of the UK and overseas than left to go in the opposite direction.
"However, for the first time in nine years net migration from the rest of the UK was larger than that from overseas.
"More people arrived in Scotland from the rest of UK and fewer people left to go in the opposite direction, compared with the previous year.
"In contrast, for the third consecutive year fewer people came to Scotland from overseas than in the preceding year."
Between mid 2012 and mid 2013 approximately 47,700 people moved to Scotland from England, Wales and Northern Ireland while roughly 39,800 people left Scotland to live in the rest of the UK.
Meanwhile, 28,200 people who were living overseas came to Scotland while 26,100 people from Scotland left to go and live overseas.