In an overlapping generations economy, households (lenders) fund risky investment projects of firms (borrowers) by drawing up loan contracts on the basis of asymmetric information. An optimal contract entails either the issue of only debt or the issue of both debt and equity according to whether a household faces a single or double enforcement problem as a result of its own decision about whether or not to undertake costly information acquisition. The equilibrium choice of contract depends on the state of the economy which, in turn, depends on the contracting regime. Based on this analysis, the paper provides a theory of the joint determination of real and financial development, with the ability to explain both the endogenous emergence of stock markets and the complementarity between debt finance and equity finance. © Blackwell Publishing Ltd 2005.