In emerging economies periods of rapid growth and large capital inflows can be followed by sudden stops and financial crises. I show that, in the presence of financial markets imperfections, a simple modification of a neoclassical growth model can account for these facts. I study a growth model for a small open economy where decreasing marginal returns to capital appear only after the country has reached a threshold level of development, which is uncertain. Limited enforceability of contracts allows default on international debt. International investors optimally choose to suddenly restrict lending when the appearance of decreasing marginal returns slows down growth. The economy defaults and enters a financial crisis.