We propose a novel approach to measure the dynamic macroeconomic effects of immigration on the destination country, combining the analysis of episodes of large immigration waves with instrumental variables techniques. We distinguish the impact of immigration shocks in OECD countries from that of refugee immigration in emerging and developing economies. In OECD, large immigration waves raise domestic output and productivity in both the short and the medium term, pointing to significant dynamic gains for the host economy. We find no evidence of negative effects on aggregate employment of the native-born population. In contrast, our analysis of large refugee flows into emerging and developing countries does not find clear evidence of macroeconomic effects on the host country, a conclusion in line with a growing body of evidence that refugee immigrants are at disadvantage compared to other type of immigrants.