Syrian refugees arrive at the camp for refugees and migrants in Friedland, Germany April 4, 2016. REUTERS/Kai Pfaffenbach

BERLIN (Reuters) - The number of people with an immigrant background in Germany rose 8.5 percent to a record 18.6 million in 2016, largely due to an increase in refugees, the Federal Statistics Office said on Tuesday.

Just over a fifth of the population - 22.5 percent - were first or second generation immigrants with at least one parent born without German citizenship, the office said.

The figures come in the build-up to national elections in September, with Chancellor Angela Merkel’s Social Democrat challenger warning against a repeat of 2015 when she opened the borders to hundreds of thousands of migrants.

Around 2.3 million people in Germany have family links to the Middle East, a rise of almost 51 percent since 2011, and around 740,000 people have African origins, an increase of 46 percent since 2011, the figures showed.

The vast majority of the immigrant population, though, had links to other European countries.

Germany took in more than a million migrants, many fleeing war and poverty in the Middle East and Africa in 2015 and 2016.

Merkel’s decision to open borders initially hit her popularity and boosted the anti-immigrant Alternative for Germany (AfD) party, though her conservatives have since recovered.