  Our main result is a theorem saying that a bounded operator $A$ on a Hilbert
space belongs to a certain set associated with its self-commutator $[A^*,A]$,
provided that $A-zI$ can be approximated by invertible operators for all
complex numbers $z$. The theorem remains valid in a general $C^*$-algebra of
real rank zero under the assumption that $A-zI$ belong to the closure of the
connected component of unity in the set of invertible elements.
  This result implies the Brown--Douglas--Fillmore theorem and Huaxin Lin's
theorem on almost commuting matrices. Moreover, it allows us to refine the
former and to extend the latter to operators of infinite rank and other norms
(including the Schatten norms on the space of matrices).
  The proof is based on an abstract theorem, which states that a normal element
of a $C^*$-algebra of real rank zero satisfying the above condition has a
resolution of the identity associated with any open cover of its spectrum.
