The National Records of Scotland (NRS) figures showed an increase of 31,700 (0.6%) people over the year to the end of June 2016.
It said the increase was due to migration, with 31,700 more people moving to Scotland than leaving.
The number of deaths exceeded births by 800, while other changes resulted in an increase of 800 people.
These other changes included variations in the prison population and in the number of armed forces personnel stationed in Scotland.
The mid-year population estimate figures for 2016 show:
Scotland's population has increased by 6% since 1996 (when it was 5,092,190)

The Public Accounts Committee at Stormont has published a damning report on the affair, after taxpayers were left to clear its Â£1.6m debts.
"The level of scandal is completely shocking," said the committee's chairperson, Michaela Boyle.
The PSNI is investigating what went on and, separately, NIEC board members are facing disqualification proceedings.
This follows a five-year inquiry costing Â£1.2m.
"This debacle makes uncomfortable reading - the scale of the mismanagement was massive," Ms Boyle said.
The NI Events Company (NIEC) was formed in 1997 to support major sports and music events.
It was answerable to the Department of Culture, Arts and Leisure (DCAL), whose oversight prior to its downfall in 2007 is described as being close to non-existent.
The department's then permanent secretary, Paul Sweeney, has already apologised and accepted responsibility for what happened.
The PAC report notes that no DCAL official has ever been disciplined.
The report said the NIEC board's performance "in key areas was extraordinarily weak" and questioned whether all its members were fully motivated.
The NIEC was the subject of an Audit Office report last September, with the conduct of its former chief executive Janice McAleese branded the worst it had seen from a public official.
Scotland's population continued to increase last year, rising to a record 5,404,700.
[NEXT_CONCEPT]
The collapse of the NI Events Company quango has been described as one of the worst scandals since devolution.