The tournament's hosts came into this game knowing that they had to win to go through and things started well for them when Alexsandr Samedov gave them the lead 25 minutes in.
The problem though was that the lead only lasted five minutes when Patricio Araujo headed home a long ball to get his side back on level terms.
The Mexicans then took the lead seven minutes into the second half when a long ball forward was misjudged by Akinfeev and Hirving Lozano pounced to head home the winning goal.
Yuri Zhirkov then saw red in the second half to compound the hosts' misery even more and that prevented them from getting an equalising goal.
The result means that the Mexicans have advanced to the semi-finals as runners-up in Group A, while the Russians have exited at the group stages much to the disappointment of the players and fans.
Both sides had early chances to take the lead
The first half was a pretty even contest as both sides started the game very well and had chances to take the lead.
Lozano had the Mexicans first chance of the game but he saw his shot from outside the box well saved by Akinfeev, while at the other end, Zhirkov put his shot just wide after a good passage of play from the hosts.
The hosts then upped the pressure midway through the second half and they almost took the lead when a fantastic drilled shot from Fyodor Smolov hit the post with the goalkeeper beaten.
Samedov fired the hosts into the lead
The miss though didn't prove costly as the hosts' did take the lead with their next attack when Dmitry Erokhin found space in the Mexican box before passing the ball to Samedov, who calmly slotted his left-footed shot into the back of the net.
Going behind though only seemed to wake the Mexicans up as Carlos Vela forced Akinfeev into a very good save from a free-kick.
Araujo levelled for the Mexicans five-minutes later
Just as the hosts did though, from their next attack, the Mexicans did get an equaliser when a long ball forward from Hector Herrera found Araujo in the box and the defender guided his header beyond Akinfeev into the back of the net.
Both sides traded blows after the equaliser but at the break the score was level with both teams showing in brief periods, how good they are at attacking.
A mistake from Akinfeev was punished by Lozano to give the Mexicans the lead
The second half took a few minutes to spring into life but then out of nowhere, the Mexicans took the lead out of nothing.
Herrera hit a long ball forward for the Mexican strikers to chase and that is exactly what Lozano did and after Akinfeev misjudged the flight of the ball, Lozano headed the ball over the keeper into the net to give his side the lead.
The Mexicans thought they had a third goal soon after when Hector Moreno put the ball into the net after an excellent cross but after the referee checked whether he was offiside via the VAR system, the goal was rightly disallowed for offside.
Zhirkov saw red as the hosts exited the competition with the Mexicans advancing to the semi-finals
That seemed to give the hosts a lift but with just over 20 minutes to go in the game, Zhirkov, who had already got a yellow card in the first half, was showing a second yellow for an elbow on Miguel Layún and therefore was sent off.
Despite having a man less though the hosts showed real spirit to try and get an equaliser and they should have got it when Igor Smolnikov, who had just came on as a second half substitute, missed from a few yards out after a fantastic cross found unmarked in the box.
After the miss, the Mexicans successfully saw the game to the close to advance to the semi-finals, while condemning the hosts to an early exit from the competition.