Msakni hit the net with a shot from outside the penalty area two minutes after the second half, to give Msakni the ticket to the quarter-finals, after qualifying from the first round among the top four teams in third place.
Nigeria played with ten men since the 64th minute after Alex Iwobi was sent off for a violent violation against Msakni.
Tunisia will meet in the quarter-finals with Burkina Faso, who beat Gabon on penalties earlier on Sunday, after they tied 1-1 after extra time.
.