We develop Commutator Theory for congruences of general algebraic systems (henceforth called algebras) assuming only the existence of a ternary term
d
d
such that
d
(
a
,
b
,
b
)
[
α
,
α
]
a
[
α
,
α
]
d
(
b
,
b
,
a
)
d(a,b,b)[\alpha ,\alpha ]a[\alpha ,\alpha ]d(b,b,a)
, whenever
α
\alpha
is a congruence and
a
α
b
a\alpha b
. Our results apply in particular to congruence modular and
n
n
-permutable varieties, to most locally finite varieties, and to inverse semigroups. We obtain results concerning permutability of congruences, abelian and solvable congruences, connections between congruence identities and commutator identities. We show that many lattices cannot be embedded in the congruence lattice of algebras satisfying our hypothesis. For other lattices, some intervals are forced to be abelian, and others are forced to be nonabelian. We give simplified proofs of some results about the commutator in modular varieties, and generalize some of them to single algebras having a modular congruence lattice.