  Let $G$ be a finite group, let $p$ be a prime and let ${\rm Pr}_p(G)$ be the
probability that two random $p$-elements of $G$ commute. In this paper we prove
that ${\rm Pr}_p(G) > (p^2+p-1)/p^3$ if and only if $G$ has a normal and
abelian Sylow $p$-subgroup, which generalizes previous results on the widely
studied commuting probability of a finite group. This bound is best possible in
the sense that for each prime $p$ there are groups with ${\rm Pr}_p(G) =
(p^2+p-1)/p^3$ and we classify all such groups. Our proof is based on bounding
the proportion of $p$-elements in $G$ that commute with a fixed $p$-element in
$G \setminus \textbf{O}_p(G)$, which in turn relies on recent work of the first
two authors on fixed point ratios for finite primitive permutation groups.
