For Nigeria, Awoniyi's strike hit the side of the net in the 37th minute, while Yahaha's long-range effort struck the crossbar just before halftime.
Both teams threatened in the opening stages of the second half, and Nigeria doubled its lead when Iheanacho took advantage of Gudino's poor attempt to clear the ball.
Mexico continued to attack and could have scored when Aguirre found Ochoa in space. But his header from right in front of goal was wide of the target.
The West Africans sealed the victory when Muhammed curled a free kick from the edge of the penalty box over the wall and past the outstretched arms of Gudino in the 81st minute.
Earlier, Sweden clinched third place after beating Argentina 4-1, thanks to Valmir Berisha's hat trick. Carlos Strandberg also scored for Sweden, while Lucio Campagnucci found the net for Argentina.
"There's a lot of feelings right now, Sweden coach Roland Larsson said. "This is my last game with this team, so this is the perfect present for me.
"This is a sensation for Swedish football; no one would believe we could do this."
Iheanacho was crowned Golden Ball winner for best player, while Sweden's Berisha earned the Golden Shoe award for most goals with seven.