Institutions of justice, like prisons, can be used to serve economic and other extrajudicial interests, with lasting deleterious effects. We study the effects on incarceration when prisoners are used primarily as a source of labor using evidence from British colonial Nigeria. We digitized sixty-five years of archival records on prisons from 1920 to 1995 and provide new estimates on the value of prison labor and the effects of labor demand shocks on incarceration. We find that prison labor was economically valuable to the colonial regime, making up a significant share of colonial public works expenditure. Positive economic shocks increased incarceration rates over the colonial period. This result is reversed in the postcolonial period, where prison labor is not a notable feature of state public finance. We document a significant reduction in contemporary trust in legal institutions, like police, in areas with high historic exposure to colonial imprisonment. The resulting reduction in trust is specific to legal institutions today.