Objectives: We aimed at exploring the underlying mechanisms and contextual conditions by which leadership may influence 'public service motivation' of health providers in Moroccan hospitals., Design: We used the realist evaluation (RE) approach in the following steps: eliciting the initial programme theory, designing the study, carrying out the data collection, doing the data analysis and synthesis. In practice, we adopted a multiple embedded case study design., Settings: We used purposive sampling to select hospitals representing extreme cases displaying contrasting leadership practices and organisational performance scores using data from the Ministry of Health quality assurance programmes from 2011 to 2016., Participants: We carried out, on average, 17 individual in-depth interviews in 4 hospitals as well as 7 focus group discussions and 8 group discussions with different cadres (administrators, nurses and doctors). We collected relevant documents (eg, performance audit, human resource availability) and carried out observations., Results: Comparing the Intervention-Context-Actor-Mechanism-Outcome configurations across the hospitals allowed us to confirm and refine our following programme theory: "Complex leaders, applying an appropriate mix of transactional, transformational and distributed leadership styles that fit organisational and individuals characteristics [I] can increase public service motivation, organisational commitment and extra role behaviours [O] by increasing perceived supervisor support and perceived organizational support and satisfying staff basic psychological needs [M], if the organisational culture is conducive and in the absence of perceived organisational politics [C]"., Conclusions: In hospitals, the archetype of complex professional bureaucracies, leaders need to be able to balance between different leadership styles according to the staff's profile, the nature of tasks and the organisational culture if they want to enhance public service motivation, intrinsic motivation and organisational commitment., Competing Interests: Competing interests: None declared., (© Author(s) (or their employer(s)) 2020. Re-use permitted under CC BY-NC. No commercial re-use. See rights and permissions. Published by BMJ.)