An Interior Ministry spokesman said the gunfight took place in Tlatlaya on the southern fringes of the State of Mexico, an area that has been plagued by gang violence in the two neighboring states of Guerrero and Michoacan.
A spokesman for federal prosecutors said all the dead were believed to be gang members.
According to Mexican media reports, the shooting started after soldiers came under fire from the suspected gang members, resulting in a gunfight lasting several minutes.
Pena Nieto took office in December 2012 pledging to quell gang violence that has claimed more than 90,000 lives since 2007. Total homicides are down in Mexico since he took over, but the death toll has risen in parts of the country.