Brazil's lower chamber of Congress has approved groundbreaking legislation aimed at guaranteeing equal access to the Internet and protecting the privacy of its users in the wake of US spying revelations.
To ensure passage of the bill, the government had to drop a contentious provision that would have forced global internet companies to store data on Brazilian servers inside the country.
The rule was added last year to proposed internet governance legislation after revelations that the US National Security Agency had spied on the personal communications of Brazilians, including those of President Dilma Rousseff.
Instead, the bill says companies such as Google and Facebook are subject to Brazilian laws and courts in cases involving information on Brazilians, even if the data is stored on servers abroad.
The government refused to drop another a key provision on net neutrality that was opposed by telecom companies because it bars them from charging higher prices for different content, such as video streaming and voice services such as Skype.
The legislation dubbed Brazil's "Internet Constitution" protects freedom of expression and sets limits to the gathering and use of metadata about internet users.
Experts, such as World Wide Web inventor Tim Berners-Lee, have praised the bill for balancing the rights and duties of individuals, governments and corporations, while ensuring the Internet continues to be an open and decentralised network.
Following the spying revelations by former NSA contractor Edward Snowden, including allegations that the NSA secretly collected data stored on servers by internet companies such as Google and Yahoo , Brazil sought to force them to store data on Brazilian servers in the country.
Internet companies complained that would push up their costs and create barriers to the free flow of information.
Those with offices in Brazil have been fined for not complying with Brazilian laws, but it is not clear how companies based elsewhere can be made to comply, for instance, with court orders to remove disputed content from the internet.
"The law is balanced because it protects internet access and privacy at the same time," said lawyer Jose Nantala, with the Peixoto e Cury law firm in Sao Paulo. "But it doesn't resolve the problem of jurisdiction in international cases," he said.
The revelations of NSA espionage using powerful surveillance programmes upset relations between the United States and Brazil and led Rousseff to cancel a state visit to Washington in October and denounce massive electronic surveillance of the Internet in a speech to the UN General Assembly.
Rousseff and German Chancellor Angela Merkel, another leader allegedly spied on by the NSA, have led international efforts to limit mass electronic surveillance. Brazil will host a global conference on the future of internet governance next month.