  We study almost inner derivations of $2$-step nilpotent Lie algebras of genus
$2$, i.e., having a $2$-dimensional commutator ideal, using matrix pencils. In
particular we determine all almost inner derivations of such algebras in terms
of minimal indices and elementary divisors over an arbitrary algebraically
closed field of characteristic not $2$ and over the real numbers.
