In a recent article [K. H. Hofmann and F. G. Russo, 'The probability that x and y commute in a compact group', Math. Proc. Cambridge Phil Soc., to appear] we calculated for a compact group G the probability d(G) that two randomly selected elements x, y ∈ G satisfy xy = yx, and we discussed the remarkable consequences on the structure of G which follow from the assumption that d(G) is positive. In this note we consider two natural numbers m and n and the probability d m,n (G) that for two randomly selected elements x, y ∈ G the relation x m y n = y n x m holds. The situation is more complicated whenever n, m > 1. If G is a compact Lie group and if its identity component G 0 is abelian, then it follows readily that d m,n (G) is positive. We show here that the following condition suffices for the converse to hold in an arbitrary compact group G: for any nonopen closed subgroup H of G, the sets {g ∈ G : g k ∈ H} for both k = m and k = n have Haar measure 0. Indeed, we show that if a compact group G satisfies this condition and if d m,n (G) > 0, then the identity component of G is abelian.2010 Mathematics subject classification: primary 20C05, 20P05; secondary 43A05.