DMX sang a song of gratitude to the Yonkers, NY cops who saved his life earlier this year … and performed for free at the charity boxing event as a token of appreciation.

X was at the Yonkers PD vs. Fire Dept. “Toughman Competition” Friday night … giving a rousing speech about the officers who found him last February lifeless in a parking lot.

DMX boosted the energy up to electric levels at the event, helping them raise $80k. The hometown rapper performed “Ruff Ryders’ Anthem” to a crowd of 2,000 … and they loved it.