BackgroundThe community-based antiretroviral therapy delivery (CBART) model was implemented in Benue State in Nigeria to increase access of key populations living with HIV (KPLHIV) to antiretroviral treatment. Key populations (KP) are female sex workers, men who have sex with men, persons who inject drugs, and transgender people. Evidence shows that the CBART model for KP (KP-CBART) can improve HIV outcomes along the cascade of HIV care and treatment in sub-Saharan Africa. However, how KP-CBART works, for whom, why, and under what circumstances it generates specific outcomes are not yet clear. Therefore, the aim of this study is to identify the initial programme theory (IPT) of the KP-CBART in Benue State using a realist approach.MethodThe study design is exploratory and qualitative, exploring the implementation of KP-CBART. We reviewed the intervention logic framework & guidelines for the KP-CBART in Nigeria, conducted a desk review of KP-CBART in Sub-Saharan Africa (SSA) and interviewed programme managers in the Benue HIV programme between November 2021 and April 2022. Findings were synthesized using the Context-Mechanism-Outcome (CMO) heuristic tool to explain the relationship between the different types of CBART models, contextual factors, actors, mechanisms and outcomes. Using a generative causality logic (retroduction and abduction), we developed, following a realist approach, CMO configurations (CMOc), summarized as an empirically testable IPT.ResultWe developed 7 CMOc and an IPT of the KP-CBART. Where KPLHIV receive ART in a safe place while living in a setting of punitive laws, harassment, stigma and discrimination, KP will adhere to treatment and be retained in care because they feel safe and trust the healthcare providers. Where KPLHIV are involved in the design, planning and implementation of HIV services; medication adherence and retention in care will improve because KP clients perceive HIV services to be KP-friendly and participate in KP-CBART.ConclusionImplementation of CBART model where KPLHIV feel safe, trust healthcare providers, and participate in HIV service delivery can improve medication adherence and retention in care. This programme hypothesis will be tested and refined in the next phase of the realist evaluation of KP-CBART.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12889-023-15774-w.