There's a record number of people calling the Big Apple home, and Brooklyn is leading the way when it comes to new residents, according to statistics released Thursday.

The population for the city reached 8,336,697 last year, a 161,564 increase from 2010, according to census data released by Mayor Michael Bloomberg.

For the first time since before 1950 there are more people moving to the city than leaving it, Bloomberg said.

The mayor and the Department of City Planning, which tracks population through census info and other sources, said a number of factors contributed to the surge in residents, such as improved safety, life expectancy and an improving economy.

"If you're going to be living here, you're going to be living a lot longer," Bloomberg said.

Of the boroughs, Brooklyn saw the greatest increase with 60,935 new residents between 2010 and 2012.

Joseph Salvo, the director of Population Division at City Planning, said some of the fastest-growing neighborhoods include Bushwick and Williamsburg.

advertisement | advertise on newsday

Marty Markowitz, Brooklyn borough president, said the various historical, cultural and entertainment draws make Brooklyn the best place to call home.

"I've always said that Brooklyn is [a] proud home to everyone from everywhere," adding that the new residents bring "even more character -- and characters -- to Brooklyn!" he said in a statement.

Queens came in second for population growth between 2010 and 2012 with a 42,049 increase, followed by Manhattan with 33,217 more residents, the Bronx with 23,365, and Staten Island with 1,998.

The Census Bureau didn't have a method of calculation for the influx of people into the city before 1950, but Salvo said the recent increase was more than an anomaly. "There are enough years of data to say this is a trend," he said.

Salvo said the main components to the growth was the 150,000 immigrants from other countries, which countered the decreasing number of people coming to the city from other U.S. states.

"The gain of immigration countered the loss of domestic migration," he said.

Salvo noted that the number of people leaving the city has been declining over the last couple of years and New Yorkers are living longer, increasing the population.

Besides touting how the city is improving, the mayor said he wants more foreigners to not only visit the outer boroughs but consider those areas a place to call home.

"We're trying to get people to see the different neighborhoods and see the opportunities," he said.