Scotland's population has reached its highest ever total of 5,347,600, according to official figures.

Life expectancy is now 77.1 years for men and 81.1 for women - up 8 and 5.8 years since 1984.

Statistics published by the National Records of Scotland (NRS) showed 82,440 people came to Scotland from the UK and overseas and 64,860 left in the year up to June 2014.

There were 29,069 marriages, 56,725 births and 54,239 deaths.

The top causes of death were cancer (15,840), ischemic (coronary) heart disease (6,872), respiratory system diseases (6,707), and cerebrovascular disease (stroke) (4,123).

Civil partnerships

Same-sex couples accounted for 367 of the marriages, while there were 436 civil partnerships - 193 male couples and 243 female couples.

The average age at which people marry for the first time increased by about two years since 2004, to 33.2 years for men and 31.4 years for women.

Other statistics revealed included:

People of Polish ethnicity in Scotland were the most economically active, but were most likely to be in lower-skilled employment

Those of Indian ethnicity were the most likely to be highly qualified and working in the top professions

Gypsies/travellers were more likely than other ethnic groups to be working the longest hours, and to be in the lowest social grade.

The 2014 records also showed the 1.3% increase in birth rate was the first rise following five consecutive annual decreases.

There were 455 adoptions recorded - about a quarter of what the figure was in the early 1970s.

And in mid-2014, there were 2.42 million households in Scotland, which was an increase of about 169,000 over the past 10 years.

Image copyright PA Image caption The increased birth rate was the first in six years

THe NRS report has been published annually since 1855.

Tim Ellis, the registrar general of Scotland, said: "This is a time of substantial demographic change: the population is increasing and ageing.

"The ageing population is the most distinctive current demographic development and will bring both opportunities and challenges.

"Life expectancy at birth in Scotland, while increasing, is lower than in the UK as a whole, and lower than a lot of other developed countries.

"There is also considerable local variation in life expectancy. Good quality data contributes to research aimed at improving the quality and cost-effectiveness of health interventions, and securing lasting improvements to the health of the people of Scotland."

Mr Ellis added: "In the last half of the 20th Century, more people tended to leave Scotland than move here.

"However, since 2001, this has changed, with more people moving to Scotland than leaving. Around 60% of people moving to Scotland are from the rest of the UK, while around 40% are from overseas. Migrants tend to be younger than the population as a whole."