This paper studies the implications of cross-border financial integration for financial stability when banks' loan portfolios adjust endogenously. Banks can be subject to sectoral and aggregate domestic shocks. After integration they can share these risks in a complete interbank market. When banks have a comparative advantage in providing credit to certain industries, they will exploit the enhanced risk sharing opportunities through more specialization in lending. The enhanced concentration in lending does not increase risk, because a well-functioning interbank market allows to achieve the necessary diversification. The greater need for risk sharing through it increases, however, the risk of cross-border contagion. Better risk sharing and greater risk of contagion tend to offset each other and financial integration improves welfare since specialization benefits are realized.