We present a holographic derivation of the entropy of supersymmetric asymptotically AdS$_5$ black holes. We define a BPS limit of black hole thermodynamics by first focussing on a supersymmetric family of complexified solutions and then reaching extremality. We show that in this limit the black hole entropy is the Legendre transform of the on-shell gravitational action with respect to three chemical potentials subject to a constraint. This constraint follows from supersymmetry and regularity in the Euclidean bulk geometry. Further, we calculate, using localization, the exact partition function of the dual $mathcal{N}=1$ SCFT on a twisted $S^1times S^3$ with complexified chemical potentials obeying this constraint. This defines a generalization of the supersymmetric Casimir energy, whose Legendre transform at large $N$ exactly reproduces the Bekenstein-Hawking entropy of the black hole.