Messi opened the scoring in the third minute but saw his strike immediately canceled out by Ahmed Musa.
The Barcelona star put Argentina back in front just before halftime with an exquisite free kick only to see Musa answer on the opposite side of the interval to bring Nigeria back on level terms.
But the winner was reserved for Rojo, who become just the second Argentine player to score a goal at the 2014 World Cup.
Messi now has amassed four goals in this year's tournament to climb level with Brazil's Neymar for the lead in the race for the Golden Boot.
The 27-year-old has been the star for Argentina, which secured first place in Group F with Wednesday's win.
Nigeria, meanwhile, advanced to the knockout round despite the loss as Iran was unable to beat Bosnia-Herzegovina in Wednesday's other Group F fixture.