  A theory of superconductivity is presented where the effect of anharmonicity,
as entailed in the acoustic, or optical, phonon damping, is explicitly
considered in the pairing mechanism. The gap equation is solved including
diffusive Akhiezer damping for longitudinal acoustic phonons or Klemens damping
for optical phonons, with a damping coefficient which, in either case, can be
directly related to the Gruneisen parameter and hence to the anharmonic
coefficients in the interatomic potential. The results show that the increase
of anharmonicity has a strikingly non-monotonic effect on the critical
temperature $T_{c}$. The optimal damping coefficient yielding maximum $T_c$ is
set by the velocity of the bosonic mediator. This theory may open up
unprecedented opportunities for material design where $T_{c}$ may be tuned via
the anharmonicity of the interatomic potential, and presents implications for
the superconductivity in the recently discovered hydrides, where anharmonicity
is very strong and for which the anharmonic damping is especially relevant.
