Immigration, immigration policies and education of immigrants alter competence levels. This study analysed their effects using PISA, TIMSS and PIRLS data (1995 to 2012, N=93 nations) for natives' and immigrants' competences, competence gaps and their population proportions. The mean gap is equivalent to 4.71 IQ points. There are large differences across countries in these gaps ranging from around +12 to -10 IQ points. Migrants' proportions grow roughly 4% per decade. The largest immigrant-based 'brain gains' are observed for Arabian oil-based economies, and the largest 'brain losses' for Central Europe. Regarding causes of native-immigrant gaps, language problems do not seem to explain them. However, English-speaking countries show an advantage. Acculturation within one generation and intermarriage usually reduce native-immigrant gaps (≅1 IQ point). National educational quality reduces gaps, especially school enrolment at a young age, the use of tests and school autonomy. A one standard deviation increase in school quality represents a closing of around 1 IQ point in the native-immigrant gap. A new Greenwich IQ estimation based on UK natives' cognitive ability mean is recommended. An analysis of the first adult OECD study PIAAC revealed that larger proportions of immigrants among adults reduce average competence levels and positive Flynn effects. The effects on economic development and suggestions for immigration and educational policy are discussed.