Messi scored Argentina's opener, but a second-half Nigeria penalty kick meant they were staring at the exit door until Marcos Rojo volleyed home the winner in the 86th minute.
Following an opening draw with Iceland and a 3-0 defeat to Croatia, the pressure on Messi and Argentina was clear, but he said the players still believed they would prevail.
"It was an amazing way to qualify," Messi told TyC Sports after the game. "It took a lot from us but we didn't deserve to go out in the first round, so we're all very happy. We knew we were going to win, but we hadn't expected it to be as tough as it was."
Messi admitted that Argentina were feeling the nerves as they pushed for a winning goal and said it was a "huge relief for all of us" to go through.
"It has been a very balanced game, we were able to control the first half, we had better possession, we tried to create opportunities even after the first goal, and we thought that the second half was going to be similar," said Messi at his postgame press conference. "However, they were able to score with the penalty, and that goal made things more difficult because then we got nervous. We had the impression of time going by faster."
The pressure to succeed and criticism from fans had led Messi to briefly announce his international retirement two years ago, but he was grateful to the supporters for being vocal in St Petersburg.
"I want to thank all the fans for the enormous sacrifice they made to be here and fill the stadium. And the people who are in Argentina suffering with us," he said. "They never let all the things they were saying about us to be in their heads, they kept believing and demonstrated that the feelings for national team is above everything."
Rojo was one of the more controversial players included in the Argentina squad after he saw his playing time decrease at Manchester United this season. But after he scored the winning goal, Messi said the defender "deserves it after fighting hard to be here."
Rojo himself said he predicted that he would get a goal against Nigeria.
"I told them, I told Ever [Banega] and [Nicolas Otamendi] that I was going to score," Rojo said. "I dedicated this to my family, they supported me in a bad time. This group of players deserve this more than anyone else. This is just the beginning."
The tests for Argentina will only get harder from here as the Albiceleste will face 1998 champions France in the round of 16 on Saturday. Messi is hoping for a fresh start.
"Our World Cup begins today," the superstar said. "We had to win any way we could, and from today this needs to be a new World Cup for us."
"We have watched every single France game," Messi said. "We have watched every single game during this World Cup. We follow every game, and France is a very good team. They have good individual players, very skilled ones, good defenders, good midfielders, very good forwards.
"They have very fast players who can really make a difference and I also have [club] teammates that I know very well, both in the front and back line. I know who they are, and I know what we have to do. It's going to be a very tough game, no doubt."
ESPN FC's Jeff Carlisle contributed to this report from St Petersburg.