  The commuting variety of matrices over a given field is a well-studied object
in linear algebra and algebraic geometry. As a set, it consists of all pairs of
square matrices with entries in that field that commute with one another. In
this paper we generalise the commuting variety by using the commuting distance
of matrices. We show that over an algebraically closed field, each of our sets
does indeed form a variety. We compute the dimension of the distance-$2$
commuting variety and characterize its irreducible components. We also work
over other fields, showing that the distance-$2$ commuting set is a variety but
that the higher distance commuting sets may or may not be varieties, depending
on the field and on the size of the matrices.
