This article presents an application of the causal inference approach to mediation analysis using the example of a complex intervention that aimed to improve the quality of care at health centres in Uganda. Mediation analysis is a statistical method that aims to isolate the causal mechanisms that make an intervention work in a given context. We combined data from a cluster randomized control trial and a mixed-methods process evaluation. We developed two causal models following our hypotheses of how the intervention was intended to work through mechanisms at health centres to improve health outcomes in the community. In adjusted analyses, there was evidence of an effect of the intervention on some health centre mechanisms; however, these did not lead to improvements in community health outcomes. We discuss the practical and epistemological challenges encountered when using mediation analysis to evaluate a complex intervention. These findings will inform future evaluations. Trial registration: The trial reported in this article is registered at: clinicaltrials.gov, NCT01024426. Registered 2 December 2009, https://clinicaltrials.gov/ct2/show/record/NCT01024426?term=NCT01024426&draw=2&rank=1