ABSTRACT: Introduction: Substandard and falsified medicines undermine health systems. We sought to unravel the political and economic factors which drive the production of these products, and to explain how they reach patients. Methods: We conducted in-depth case studies in China, Indonesia, Turkey and Romania. We reviewed academic papers and press reports (n = 840), developing semi-structured questionnaires. We interviewed regulators, policy-makers, pharmaceutical manufacturers, physicians, pharmacists, patients and academics (n=88). We coded data using NVivo software, and developed an analytic framework to assess national risks for substandard and falsified medicines. We tested the framework against cases reported to the World Health Organization, from countries at all income levels. Results: We found that increasing political commitment to provision of universal health coverage has led to public procurement policies aimed at lowering prices of medical products. In response, legitimate, profit-driven pharmaceutical companies protect their margins by cutting costs, or withdrawing from less profitable markets, while distributors engage in arbitrage. Meanwhile, health providers sometimes protect profits by 'upselling' patients to medicines not covered by insurers. Cost-cutting can undermine quality assurance, leading to substandard or degraded medicines. Other responses contribute to shortages, irrational demand and high prices. All of these provide market opportunities for producers of falsified products; they also push consumers outside of the regular supply chain, providing falsifiers with easy access to customers. The analytic framework capturing these interactions explained cases in most high and middle-income settings; additional factors operate in the poorest countries. Conclusions: Most efforts to secure medicine quality currently focus on product regulation. However, our research suggests market mechanisms are key drivers for poor quality medicines, including where political commitments to universal health coverage are under-resourced. We have developed a framework to guide country-specific, system-wide analysis. This can flag risks and pinpoint specific actions to protect medicine quality, and thus health.