Scotland's population has grown to a record 5.4 million following another rise in migration.

New figures from the National Records of Scotland show 5,404,700 people living in Scotland as of June 2016, up from 5,373,000 the previous year.

The increase has been attributed to immigration, with 46,300 people coming to Scotland from the rest of the UK, compared with 37,500 leaving for the rest of the UK, and 40,400 coming from overseas, compared with 17,500 leaving for overseas.

The net gain of 32,000 compares to 28,000 in the previous year and is the highest net in-migration figure since 2006/07.

Migrants tended to be younger, with a peak age for moves into Scotland of 19 while it is 23 for those leaving.

The figures also show 54,488 births were registered in Scotland in 2016, 1.1% fewer births than in 2015 and the lowest annual total since 2005.

Meanwhile 56,728 deaths were registered, 1.5% fewer than in 2015.

The population is projected to grow older as life expectancy improves, with the number of people aged 75 and over forecast to increase by 85% from 0.43 million in 2014 to 0.8 million in 2039, and the number of people aged 65 to 74 expected to rise by 27% from 0.54 million to 0.68 million.

An increase in deaths from dementia and Alzheimer's disease was partly attributed to people living longer.

Deaths from the diseases have more than doubled since 2000, according to the data, and have now overtaken deaths from cerebrovascular disease such as strokes.

The single biggest cause of death is still cancer, which has risen by 6% between 2000 and 2016.

Tim Ellis, the Registrar General of Scotland, said: "Scotland's population has continued to age over the past decade, with the greatest increases in the population in the older age groups.

"Over the next 25 years, there is a projected increase of 28% in the number of pensioners in Scotland, compared to an increase of just 1% in the number of people of working age.

"This has implications for funding allocations, tax revenues, pensions, education, health and social care provision."