The calculation of the partition function for N M5-branes is addressed for the case in which the worldvolume wraps a manifold T 2 × M4, where M4 is simply connected and Kaehler. This is done in a compactification of M-theory which induces the Vafa-Witten theory on M4 in the limit of vanishing torus volume. The results follow from the equivalence of the BPS spectrum counting in the complementary...