A perennial question in political science is the degree to which bureaucratic selection is influenced by competence vis-à-vis political loyalties. In this paper, I first combine a novel dataset containing the individual careers of about 325,000 Chilean central government bureaucrats (2006-2020) with data for twelve years of university admissions test scores (1996-2007), matching about 90,000 of them. Using this fine-grained measure of cognitive ability, I find that test scores are highly predictive of bureaucratic advancement, and show evidence suggesting that selection on ability, and not just on class origin, drives this result. I then add data on civil servants’ membership in centre-left (governing) parties for 2017, finding that, in professional and managerial positions, political loyalties indeed partially substitute for cognitive ability: party members have lower scores than comparable non-members. I thus provide a “shadow price” for the trade-off between ability and party loyalty at different levels of the administrative hierarchy.