We present a theory of a partial economic reform of a planned economy, similar to the one that took place in Russia since 1988 and in China earlier. In such a reform, some markets are liberalized in the sense that producers can sell output to whomever they want, including private firms, at free prices, but at the same time must sell to state firms at state prices. We show that such a reform can result in a substantial diversion of subsidized inputs away from state firms and toward private firms even when state firms value these inputs more. The result may be a reduction of total output. The simple analysis sheds light on many consequences of the Soviet reform, such as breakdown of coordination of production, increased state policing of delivery quotas, prohibitions of trading cooperatives, and opposition to privatization. The model also explains why partial reform failed in Russia but worked in China.