  In this paper we prove the fundamental lemma for Deligne-Lusztig functions.
Namely, for every Deligne-Lusztig function $\phi$ on a $p$-adic group $G$ we
write down an explicit linear combination $\phi^H$ of Deligne-Lusztig functions
on an endoscopic group $H$ such that $\phi$ and $\phi^H$ have ``matching
orbital integrals''. In particular, we prove a conjecture of Kottwitz. More
precisely, we do it under some mild restriction on $p$.
