No group immediately claimed responsibility for the attack on Monday, which came amid protests by groups opposed to Brazil hosting the World Cup in June and July.
Police and government security teams were investigating the extent of the attack. The ministry shut down its email communications for a day.
The spokesman said sensitive information sent through the email system was encrypted, but employees at the ministry and Brazilian embassies abroad were told to change their passwords.
Brazil in April passed comprehensive Internet privacy legislation in what some liken to a Web-user's bill of rights, after stunning revelations its own president was targeted by US cyber-snooping.
"The bill sets out principles, guarantees, rights, and duties for Internet users, and Internet service providers" in Brazil, a statement on the Senate's website had said.
Also in April, Brazil held the NETmundial conference for global leaders and the biggest Web firms to discuss Internet legislation.
Big Internet companies were the clear winners at the global conference on the future management of the Web where most participants agreed it should remain a self-regulated space free of government intervention.
Convened by President Dilma Rousseff after revelations of U.S. surveillance undermined trust in the Internet, the NETmundial conference concluded that governments, companies, academics, technicians and users should all have a say in where to go next.
Written with agency inputs
For the latest tech news and reviews, follow Gadgets 360 on X, Facebook, WhatsApp, Threads and Google News. For the latest videos on gadgets and tech, subscribe to our YouTube channel. If you want to know everything about top influencers, follow our in-house Who'sThat360 on Instagram and YouTube.