BERLIN (AP) — The refugee crisis and the threat of terrorism in Europe are very much related to one another in the minds of many Europeans, according to a survey conducted across the continent.

Monday’s poll by the Pew Research Center found that in eight of the ten European nations surveyed, half or more believe that the influx of migrants increases the likelihood of terrorism in their country. Many Europeans also worry that migrants will become an economic burden and take away their jobs and social benefits.

The survey covered the European countries of Germany, Sweden, the Netherlands, Britain, France, Spain, Italy, Greece, Hungary and Poland. It was conducted from April to May — before the British referendum to leave the European Union and the extremist attack at Istanbul’s Ataturk Airport last month.

The continent saw an overwhelming influx of more than one million migrants in 2015 — with the majority arriving from Muslim countries such as Syria, Iraq and Afghanistan. Almost all of them applied for asylum in the EU with Germany and Sweden as their top destinations.

Meanwhile, populist parties all over the continent successfully increased their numbers by campaigning against Muslim migrants, including the National Front in France, the UK Independence Party, the right-wing Alternative for Germany and Austria’s Freedom Party.

Europe has recently suffered several major terrorist attacks, including the assaults by the Islamic State group on Paris and Brussels that killed scores of people. Many of the attackers were European-born, but some are believed to have traveled to Syria to join IS before returning to carry out the attacks — a few of them by mixing in with migrant flows to avoid detection on their way home.

Some 76 percent of people surveyed in Hungary said they’re concerned that refugees will increase the likelihood of terrorism in their country, followed by the Polish with 71 percent. Majorities in all other surveyed countries shared this belief — with the exception of Spain and France.

Citizens of both Hungary and Poland also worried more than other Europeans that refugees would be a burden to their countries because they would take their jobs and social benefits.

“It is important to note that worries about refugees are not necessarily related to the number of migrants coming to the country,” the report states.

It said Poland, where 73 percent say refugees are an overall major threat, has had only several thousand asylum applications, while just 31 percent of Germans are generally concerned about refugees after seeing their country register almost 1.1 million asylum seekers last year.

German Chancellor Angela Merkel has made the successful handling of the refugee crisis her top priority and has told Germans time and again that “we will manage this.” The government of Hungary, on the other hand has been an insistent voice against migrants, especially against Muslims.

Germany and Sweden — which took in the second most asylum seekers in 2015 — are the only countries where at least half say refugees make their nations stronger because of their work and talent.

When asked more generally, whether having an increasing number of people of many different races, ethnic groups and nationalities in their country makes the society a better place to live in, only few Europeans said diversity has a positive impact. At 36 percent, Sweden registers the highest percentage that believes diversity makes their country a better place to live.

The prevailing attitude in France, Germany, the Netherlands and Spain is that diversity is neither a plus nor a minus in term of quality of life. At the same time, 63 percent in Greece and 53 percent in Italy believe that growing diversity makes their country a worse place to live.

These attitudes stand in a stark contrast to the U.S. There, some 58 percent of Americans said having more people of many different races, ethnic groups and nationalities makes the U.S. a better place to live. Only 7 percent said increasing diversity makes life worse, according to a Pew Reserach Center poll conducted in March.

The poll was conducted from April 4 to May 12 among 11,494 people in Europe and the United States. Data from the U.S. was mostly used for comparisons.

The margin of error ranged from 3.1 to 4.6 percent.

___

Pablo Gorondi in Budapest, Hungary, contributed to this story.