In health care, multilevel models are typically used to evaluate hospitals' performance and to rank hospitals accordingly. While multilevel models capture the hierarchical structure in the data, such as the grouping of patients into hospitals, these models do not account for additional latent structures. In this paper, we develop a novel multilevel logistic cluster‐weighted model which can predict a binary outcome, such as mortality within 30 days of discharge, while accounting both for known and latent structures of the data. We develop an Expectation‐Maximization algorithm for parameter estimation and a parametric bootstrap approach for assessing the variability of the estimators. Using a rich data set of the Lombardy (Italy) health care system and focussing on the two wards of cardiosurgery and medicine, we show how the proposed model detects, in both cases, two well‐defined clusters within the patient to hospital hierarchical structure of the data. A comparison with standard multilevel and cluster‐weighted approaches reveals a better fit of the proposed model and a greater insight into the structure of the data. We show how this can have implications in the resulting league tables and thus how the proposed model can be a useful tool for policy‐makers and healthcare managers to conduct hospital evaluations.