The ministry websites as well as several local government sites went down early on Thursday afternoon and could still not be accessed.
A spokesman for the Mexican Defense Ministry said only that the website was experiencing technical difficulties.
Anonymous, a loosely knit group that has attacked financial and government websites around the world, said it orchestrated the shutdowns as part of what it termed OpIndependencia, but did not give a reason for its actions.
Thursday evening marks the anniversary of the start of Mexico's fight for independence from Spain in 1810. It will be celebrated with a public holiday on Friday.
"We are anonymous, we are legion, we don't forgive, we don't forget. Wait for us," said a statement on a blog linked to a Twitter account for Anonymous Hispano.
Anonymous said via Twitter it was also targeting President Felipe Calderon's home page. That site is still up.
Anonymous attracted headlines when it attacked the websites of companies and institutions that opposed WikiLeaks and its founder, Julian Assange, after that group released a trove of sensitive military and diplomatic materials.