The counting of microstates of BPS black-holes on local Calabi-Yau of the form (p-2)?(-p) S2 is explored by computing the partition function of q-deformed Yang-Mills theory on S2. We obtain, at finite N, the instanton expansion of the gauge theory. It can be written exactly as the partition function for U(N) Chern-Simons gauge theory on a Lens space, summed over all non-trivial vacua, plus a tower of non-perturbative instanton contributions. In the large N limit we find a peculiar phase structure in the model. At weak string coupling the theory reduces to the trivial sector and the topological string partition function on the resolved conifold is reproduced in this regime. At a certain critical point, instantons are enhanced and the theory undergoes a phase transition into a strong coupling regime. The transition from the strong coupling phase to the weak coupling phase is of third order. © 2006 IOP Publishing Ltd.