BRASILIA, Brazil — Brazil demanded answers Tuesday from the U.S. about National Security Agency spying in the country and warned that trust between the two nations would be damaged if U.S. explanations about the program were not satisfactory.

U.S. Secretary of State John Kerry, who was visiting Brasilia, sought to allay Brazil’s concerns about the program, saying the U.S. would work to provide answers to Brazil and other Latin American nations rankled by the NSA surveillance revealed by systems analyst Edward Snowden.

“We’re now facing a new type of challenge in our bilateral relationship,” Brazil Foreign Minister Antonio Patriota said at a news conference. “The challenge is related to news about the interception of Brazilian electronic and telephone communications. And if those challenges are not resolved in a satisfactory way, we run the risk of casting a shadow of distrust over our work.”

He said Brazil was seeking explanations through political, diplomatic and technical channels, but that those clarifications were not an “end to themselves.”

“We need to stop practices that violate sovereignty, ” he said.

The O Globo newspaper reported last month that information released by Snowden showed Brazil is the top target in Latin America for the NSA’s massive intelligence-gathering effort, aimed at monitoring communications around the world.

Public opposition to the spying was on display outside the Foreign Ministry building on Tuesday as a few dozen protesters yelled “go away, spies” to some members of Kerry’s traveling party as they left the building.

Kerry defended the NSA program, saying it had been approved by all three branches of the U.S. government.

“We’re not surprised and we’re not upset that Brazil would ask questions. Absolutely understandable,” Kerry said.

“Brazil is owed answers with respect to those questions and they will get them. And we will work together very positively to make certain that this question — these issues — do not get in the way of all the other things that we talked about,” Kerry said.

He said he could not discuss operational issues, but said the U.S. is talking to the Brazilians about the program.

“We will guarantee that Brazil and other countries will understand exactly what we are doing — why and how — and we will work together to make sure that whatever is done is done in a way that respects our friends and our partners. And that is what we are going to achieve.”

Revelations about NSA snooping in Brazil came at a time when the U.S. has been trying to expand the relationship with Brazil, an economic powerhouse in Latin America.

During President Barack Obama’s visit to Brazil in 2011, the two nations signed 10 bilateral agreements. Five more were signed when Brazil President Dilma Rousseff visited the United States earlier this year, evidence of enhanced cooperation between the two countries.

Rousseff, who met with Kerry Tuesday afternoon, has been invited again to Washington in October, when Obama hosts a state visit for Brazil.

Both Patriota and Kerry boasted that the U.S.-Brazil relationship had matured and that the two nations were working together on many issues, including trade, energy, gender equality, sustainable development, deforestation, climate change, biofuels and visa-free travel between the two countries.

Kerry said the U.S. did not want the surveillance dispute to taint relations.

“I want to emphasize, rather than focus on an area of disagreement, the United States and Brazil share a remarkable and dynamic partnership,” Kerry said. “Every single day, we work together to advance economic opportunity, human rights, environment protection, regional peace and security, democracy as well as major global challenges in the Middle East and elsewhere.”

He said the U.S. respected that Brazil is one of the world’s largest free-market democracies. Brazil’s foreign minister on Tuesday said that U.S. investment in the country had surpassed $100 billion and that tens of millions of dollars continue to flow in annually, a statistic that shows that Brazil is an attractive destination for American investors.

In February, Warren Buffett’s Berkshire Hathaway and the Brazilian firm 3G announced they agreed to buy ketchup-maker H.J. Heinz. The secretary’s wife, Teresa Heinz Kerry, is the widow of former U.S. Senator John Heinz, and heir to the Heinz ketchup fortune. Brazil’s 3G, owned by Jorge Lemann, one of Brazil’s richest men, is best known for its acquisition of Burger King and its role in the deal that created Anheuser-Busch InBev, the world’s biggest beer maker.

Kerry began his one-day visit to Brazil with a stop at an educational institute. Brazil’s Scientific Mobility Program aims to train 101,000 Brazilian students overseas and have them return to their homeland to make use of their newly acquired knowledge in science and technology. Rousseff plans to have 47,000 of those students trained in the United States. This dovetails with Obama’s 100,000 Strong Initiative to bring 100,000 Latin American students to the United States and send the same number of U.S. students to that region.

Kerry walked through a science fair where future or former students, like Pedro Mehme, showed him their inventions. The 21-year-old from Brasilia, who studied electrical engineering at the University of Brazil and also studied in the United States, showed Kerry a cylindrical device that rises into the atmosphere via a helium balloon. At 32 kilometers, the balloon bursts, a parachute is activated and the device travels back to the ground taking photos and collecting data.

Mehme recently won a contest that will allow him to take a sub-orbital space flight in 2015 and become the first Brazilian in space.

Kerry asked him what he planned to do while in orbit.

“I’m not sure,” Mehme said. “It’s only going to be a one-hour flight.”

Only subscribers are eligible to post comments. Please subscribe or to participate in the conversation. Here’s why.

Use the form below to reset your password. When you've submitted your account email, we will send an email with a reset code.