This paper develops a theory of international trade in which financial development and factor endowments jointly determine comparative advantage. We apply the financial contract model of Holmstrom and Tirole (1998) to the Heckscher-Ohlin-Samuelson (HOS) model in which firms' dependence on external finance is endogenous, and the demand for external finance is constrained by financial development. The theory nests HOS model as a special case. A key result that emerges is what we call the law of a wooden barrel: if the external finance constraint is binding, then further financial development will increase the output of the industry more dependent on external finance, and decrease the output of the other industry. It is shown that financial development makes both labor and unemployed capital better off, but incumbent capital worse off. Therefore, financial development depends on the relative strength of political forces among labor, unemployed capital owners, and incumbent capital owners. If only the capital constraint is binding, on the other hand, the standard HOS predictions will apply.