Brazil - a vocal critic of widely reported U.S. intelligence gathering inside its borders - has itself admitted spying on foreign diplomatic operations, including those of the United States, Iran and Russia.
But a statement Monday from the Brazilian intelligence agency Abin said its spy operations, conducted in 2003 and 2004, complied with Brazilian law aimed at protecting national interests.
The spying acknowledgement came hours after a report in the Folha de Sao Paulo newspaper described how government agents tracked and photographed Russian and Iranian diplomats. The report also said the agency monitored commercial property leased by the U.S. embassy in Brasilia and used as a relay station for embassy communications.
The Brazilian spy agency statement also said the spying disclosure to Brazilian reporters was illegal and those found to have leaked the information will be prosecuted.
The U.S. embassy in Brasilia declined comment on the Brazilian spying acknowledgment.
The spying revelations come six weeks after Brazilian President Dilma Rousseff canceled plans for a state visit to the United States. The cancellation was triggered by published reports citing secret U.S. documents showing the U.S. National Security Agency spied on Rousseff's electronic communications and those of Brazil's state-run oil company.
Those U.S. documents - disclosed by a disaffected former NSA worker - also showed the NSA collected data on billions of emails and telephone calls routed through Brazil over international cables.
U.S. officials have defended the NSA surveillance, saying it was aimed at detecting and tracking suspected terrorist activity.