The South American side needed to beat the Super Eagles in their last game of the group stage to secure their progression to the last 16, but looked to be heading out after a Victor Moses penalty had cancelled out impressive Messi's first-half opener.
But it appears that the coach may have asked captain Messi for permission before making the call to bring off defender Nicolas Tagliafico for Aguero.
Argentine news outlet TYC Sports filmed Sampaoli speaking with Messi prior to Aguero's substitution, with the Barcelona superstar nodding his head in response to a question, believed to be "Lo pongo el Kun?" In English, that loosely translates to "Shall I put on Kun?"
The Manchester United defender, inexplicably in the Nigeria penalty area in the closing stages, fired a superb volley into the bottom corner from Gabriel Mercado's cross just moments after a brief scare with VAR for an accidental handball in his own box.
The win saw Sampaoli's team finish second in Group D, five points behind Croatia and one above Nigeria, and the Albiceleste will now face Group C winners France in the last 16.
Despite the need for a late goal to earn a first win of the tournament and keep his team in it, Sampaoli feels they deserved their late fortune.
"After the penalty we got nervous and were worried about not going through, but we were very happy at the end," he said.
"As I have said before, my players play with heart, they are true rebels. They had a very difficult thing to do, and this is now a good opportunity for the future.
"The first half today was great. Now we need consistency in the future. We’ve managed to do so and have been able to go through. Every match is a final. We need to be cohesive to win against France."