This paper develops a new international trade model with capital market imperfections and endogenous borrowing costs in general equilibrium. A key element of our model is that firm heterogeneity arises from the interaction of credit constraints at the firm-level with financial frictions at the country-level. Producers differ in pledgeability of sales which results in firm heterogeneity, if financial institutions are imperfect. We show that endogenous adjustments of capital costs represent a new channel that reduces common gains from globalization. Trade liberalization increases the borrowing rate, leads to a reallocation of market shares towards unconstrained producers and a larger fraction of credit-rationed firms. This increases the within-industry variance of, sales and reduces welfare gains as consumers dislike price heterogeneity. Our theory is consistent with new empirical patterns from World Bank firm-level data. We highlight that credit frictions are positively related to the degree of product market competition and to the variance of sales across firms.