RIO DE JANEIRO — President Obama said Friday that he was seeking to ease tensions with the leaders of Latin America’s two largest nations, Brazil and Mexico, over reports that the National Security Agency had spied not only on their nations, but on them and their inner circles as well.

At a news conference at the Group of 20 summit meeting in St. Petersburg, Russia, Mr. Obama said he had told President Dilma Rousseff of Brazil and President Enrique Peña Nieto of Mexico that “I take these allegations very seriously.”

“I understand their concerns; I understand the concerns of the Mexican and Brazilian people, and that we will work with their teams to resolve what is a source of tension,” Mr. Obama said.

The assurances notwithstanding, Ms. Rousseff continued to express disdain for the spying, contending that it put Brazil’s economic interests and sovereignty at risk. Even after meeting with Mr. Obama to discuss the issue at the summit meeting, she said a state visit to the United States planned for October could be canceled.