Delegating the allocation of public resources to community members is an increasingly popular form of delivering development programs and are associated with a tradeoff between improved information about potential beneficiaries and favoritism towards local elites. Unlike targeting cash transfers to the poor, the optimal targeting of credit is a more complex problem involving issues of productivity, repayment, and market responses: This paper analyzes this problem using a large-scale lending program, the Thai Million Baht Credit Fund, which decentralizes the allocation of loans to an elected group of community members, and provides three main results. First, exploiting a long and detailed panel, I recover pre-program structural estimates of household total factor productivity and find that resources from the program were not allocated to high-productivity, poor households, which is inconsistent with poverty and productive efficiency as targeting criteria. Second, using socioeconomic networks data, I show that actual targeting is strongly driven by connections to village elites and is related to lower program profitability, which suggests favoritism as a reason for mistargeting. Finally, I exploit quasi-experimental variation in the rollout of the program and uncover evidence that, in general equilibrium, informal credit markets compensate for targeting distortions by redirecting credit towards unconnected households, albeit at higher interest rates than those provided by the program. The results highlight the limitations of community-driven approaches to program delivery and the role of markets in attenuating potential targeting errors.