We analyze the structure and attributes of subprime mortgage-backed securitization deals originated between 1997 and 2007. Our data set allows us to link loan-level data for over 6.7 million subprime loans to the securitization deals into which the loans were sold. We show that the securitization process, including the assignment of credit ratings, provided incentives for securitizing banks to purchase loans of poor credit quality in areas with high rates of house price appreciation. Increased demand from the secondary mortgage market for these types of loans appears to have facilitated easier credit in the primary mortgage market. To test this hypothesis, we identify an event which represents an external shock to the relative demand for subprime mortgages in the secondary market. We show that following the SEC's adoption of rules reducing capital requirements on certain broker dealers in 2004, five large deal underwriters disproportionately increased their purchasing activity relative to competing underwriters in ZIP codes with the highest realized rates of house price appreciation but lower average credit quality. We show that these loans subsequently defaulted at marginally higher rates. Finally, using the event as an instrument, we demonstrate a causal link between the demand for mortgages in the secondary mortgage market and the supply of subprime credit in the primary mortgage market.