SAO PAULO — Brazilian President Dilma Rousseff on Wednesday ratified a bill guaranteeing Internet privacy and enshrining access to the Web during a major conference in Sao Paulo on the future of Internet governance.

The legislation, which was passed by the Senate late Tuesday, puts limits on the metadata that can be collected from Internet users in Brazil. It also makes Internet service providers not liable for content published by their users and requires them to comply with court orders to remove offensive material.

Brazil has cast itself as a defender of Internet freedom following revelations last year that Rousseff was the object of surveillance by the United States’ National Security Agency. She cancelled a state visit to the U.S. last October over the revelations, which came out of leaks by former NSA analyst Edward Snowden and showed Brazil’s state-run Petrobras was also the object of American spying.

Rousseff had championed a measure requiring Internet companies to store the data of Brazilian users inside the country, as a way of protecting citizens from further U.S. spying, but clause was cut from the final bill amid fears it would prove too challenging to implement.

Rousseff signed the bill into law early Wednesday ahead of her opening remarks at the NETmundial conference in Sao Paulo. Representatives from dozens of countries were in attendance, as were top Internet figures including a Google vice president and the head of the U.S.-based organization that coordinates the Internet naming system.

Rousseff praised Congress for passing the legislation, which she said “guarantees the neutrality of the Web, which is fundamental to maintaining the Internet’s free and open nature.”

“Our legislation can influence the worldwide debate aimed at finding a way to guarantee real rights in a virtual world,” Rousseff’s official blog quoted her as saying.

The blog also quoted Justice Minister Jose Eduardo Cardozo as hailing the legislation as “historic” and a “victory for Brazilian society, for the Brazilian government and for the Brazilian legislature.”

“I believe that neutrality, privacy, freedom and the absence of discrimination that the text guarantees are really going to put Brazil in the vanguard, as a model for various other countries that are going to want to recreate the same principles, the same condition that are enshrined in our law,” Cardozo was quoted as saying.