The captain took advantage of a slip by Niger's goalkeeper Daouda Kassaly, who spilled a cross from Fousseiny Diawara right at Keita's feet and he swept it into the net in the 84th minute at Port Elizabeth's Nelson Mandela Bay Stadium.
It came as reward for a long period of dominance by Mali against a spirited but outgunned Niger, who were hoping for a first ever point in the finals.
The victory followed three successive draws on the opening weekend of the continental championship in South Africa.
Keita had just minutes earlier hit the woodwork with a similar close in effort.
Mali turned up the heat in the closing stages bringing on Momo Sissoko and Samba Diakite to add bite to the midfield and allow Keita to push forward alongside the two strikers.
Mali had the better of limited exchanges in a pedestrian first half, but Mahamane Traore and Mahamadou Ndiaye were both off target.
They also found it hard to get clear-cut chances after the break as their attacks became increasingly desperate.
Niger played a cautious game, seeking chances on the counter-attack but in the end were let down by an elementary error.
"It was our plan against a big Mali team to try and hold out as long as possible and we defended well until we let in the goal. I have to congratulate my players even though we lost," said Niger coach Gernot Rohr.
Niger now play the Democratic Republic of Congo on Thursday while Mali meet Ghana in the next series of Group B games.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.