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.
External affairs minister Humza Yousaf said: "Healthy population growth is vital for our future economic growth and so the continuing increase in these figures is welcome news.
"The sustained trend over the last 10 years is positive, with more people coming to Scotland from the rest of the UK than leaving.
"We value the contribution migrants make to our economy, our culture and our society.
"That is why we are working hard to attract the best international talent to our universities and our workforce, and why those who choose to make Scotland home will always be welcomed.
"The Scottish Government welcomes the contribution new Scots can make to our economy and society, and these figures show that Scotland is an attractive and dynamic nation and one where people want to make a life for themselves."
He claimed: "The UK Government's focus on arbitrarily reducing net migration irrespective of what value migrants might bring, what skills shortages they could address, or what contribution they could make to our economy and society, is wrong for Scotland and is harming our economic prospects."
Mr Yousaf added: "This approach has dramatically reduced the number of international students coming to Scotland from countries that have traditionally sent high numbers and undermines the Scottish Government's efforts to attract the best international talent to our universities and our workforce.
"With full responsibility for immigration, an independent Scotland would be able to support the needs of Scottish businesses and help to address Scotland's own demographic challenges.
"It would give Scotland the ability to tailor a robust new approach to migration to address our own specific social, economic, educational and demographic needs."