Scotland's population has reached a record high, new estimates suggest.

The population on June 30 last year was 5,313,600, up 13,700 from mid-2011 and up 18,200 from the census in March 2011, according to National Records of Scotland (NRS).

There were 2,577,140 males and 2,736,460 females. The number of both males and females was the highest ever.

NRS chief executive Tim Ellis said: "Scotland's population has continued to grow, reaching its highest-ever level last year. The increase from the census in 2011 to end June 2012 was 18,200.

"The rise was because there were over 6,000 more births than deaths and a net in-flow of 15,200 more people coming to Scotland than leaving.

"Most of this net migration increase is from people coming to Scotland from overseas rather than from the rest of the UK.

"Overall however, fewer people came to Scotland from overseas and more people left to go overseas in the year to mid-2012, than in the previous year."

Across the UK, the total population has grown by more than 400,000 to 63.7 million. The estimated population of England now stands at 53.5 million, 3.1 million in Wales and 1.8 million in Northern Ireland..

The growth of 419,900 in the past year means the UK has had the biggest growth of any country in Europe in the year to June 30 2013 and it is now the third largest EU nation behind Germany and France, according to the Office for National Statistics (ONS) figures.

France's population grew by 319,100 in the past year to 65,480,500 while Germany's population went up by 166,200 to 80,399,300, the ONS said.

The UK had its biggest baby boom since 1972 as 813,200 births were recorded in the past year. There were 558,800 deaths during this period.

The UK's population increase can be tracked back to the fact that there were 254,400 more births than deaths and net migration levels of 165,600, the ONS said.

A drop in the smoking habit plus improvements to health treatments for circulatory illnesses has seen more men living past the 75-year marker. This is why the number of men aged 75 and over in the UK has increased by just over 26%, or 422,353, since mid-2001 to 2,043,034 now.

Migration from overseas accounted for 517,800 of the population flow into the UK while 352,100 people left the country, puttng net migration at 165,600 for the year.

Fewer people came to Scotland from abroad and more people left the country, the figures show.

An estimated 35,900 people came to Scotland in the 12 months to June last year, compared with 42,300 in the same period to June 2011.

Around 26,200 moved overseas in the 12 months to June last year, compared with 16,900 over the year to June 2011.

The balance of 9,700 immigrants to mid-2012 is less than two-fifths of the 25,400 balance recorded in the 12 months to mid-2011.

More people came to Scotland from the rest of the UK but more people also went the other way, resulting in a steady annual rise in UK migration of around 3,000 a year.

Around 45,116 people came to Scotland from elsewhere in the UK in the year to June 2012, compared with 43,686 to mid-2011.

Around 42,078 left Scotland to live elsewhere in the UK in the year to mid-2012, compared with 40,777 to mid-2011, leaving a balance of around 3,000 growth each year.

The rising birthrate has also slowed with 4,223 more births than deaths to June 2012, compared with 4,809 to mid-2011.

But economists say Scotland's population needs to grow by 24,000 people a year just to keep pace with European economies.

External Affairs Secretary Fiona Hyslop said the population growth continues "in the right direction" to achieve this target.

"The Scottish Government has set a target to match average European population growth over the period 2007 to 2017. Today's figures show that we continue in the right direction," she said.

"While, like almost every mature economy, we have an ageing population, it is excellent to see the under-fives population has increased."

Net in-flow of people coming to Scotland from overseas "is proof that Scotland is an attractive and dynamic nation and one where people want to make a life for themselves".

She said: "The Scottish Government welcomes the contribution these new Scots can make to our economy and society, and we are working hard 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."

Population growth in the 12 months to June last year was the lowest in almost a decade, the Conservatives pointed out.

They criticised the Government for hailing the 18,200 growth in population since the census which covers a 15-month time-scale, when the year-on-year figures actually point to a "slowdown".

The 13,700 growth to June last year compares with average increases of around 25,000 a year in the last decade.

Tory finance spokesman Gavin Brown said: "A country like ours needs people, particularly young people, to come in to work and increase the tax base. That is absolutely essential for the economy. So for this increase to halve could prove extremely significant, especially compared to the growth rate before.

"It could just be a one-year blip but the minister in charge at the Scottish Government needs to find out why this is and what can be done, and explain as quickly as possible what the solution will be."

Growth to June last year comprised 9,700 net overseas immigrants, 3,038 UK migrants and 58,458 births, minus 54,235 deaths and 3,261 other deductions to take account of the movement of Armed Forces personnel, prisoners and statistical adjustments.