PurposeThe purpose of this paper is to investigate the influence of transformational leadership and transactional leadership styles on the retention of public librarians in Gauteng Province in South Africa.Design/methodology/approachThis quantitative study used a survey research design to target a population of 394 librarians in municipal libraries in Gauteng Province, South Africa. A proportional stratified sampling was used to target a total of 191 respondents. A total of 120 respondents completed and returned the survey, resulting in a response rate of 62.2%. Data were analysed using the Statistical Package for the Social Sciences (SPSS) version 28.FindingsThe findings reveal that transformational and transactional leadership styles have a positive impact on librarian retention. In addition, transformational leadership style is observed to have more impact on employee retention compared to transactional leadership practice.Practical implicationsThe results could be used as the basis for avoiding significant spending on ineffective leadership programmes and unprofitable directions to retain librarians in light of the multitude of leadership models.Originality/valueTo date, there is limited research on the impact of transformational and transactional leadership styles on the retention of public librarians in the context of public libraries in South Africa.