A result of Stieltjes famously relates the zeroes of the classical orthogonal polynomials with the configurations of points on the line that minimize a suitable energy with logarithmic interactions under an external field. The optimal configuration satisfies an algebraic set of equations: we call this set of algebraic equations the Stieltjes–Fekete problem. In this work we consider the Stieltjes-Fekete problem when the derivative of the external field is an arbitrary rational complex function. We show that, under assumption of genericity, its solutions are in one-to-one correspondence with the zeroes of certain non-hermitian orthogonal polynomials that satisfy an excess of orthogonality conditions and are thus termed “degenerate”. When the differential of the external field on the Riemann sphere is of degree $3$ our result reproduces Stieltjes’ original result and provides its direct generalization for higher degree after more than a century since the original result.