The lower House of Deputies had passed the bill earlier, and late Tuesday the Senate gave it a green light. That leaves only the expected signature into law from President Dilma Rousseff.
"The bill sets out principles, guarantees, rights, and duties for Internet users, and Internet service providers" in Brazil, a statement on the Senate's Website said.
The law is aimed at balancing freedom of expression and the Web-users' rights to privacy and protection of personal data, Rousseff says.
Still, Brazilian authorities do not control what happens outside their country; the government-backed law stopped short of requiring companies such as Google and Facebook to store local users' data in Brazilian data centers.
Rousseff has spoken out forcefully against cyber-snooping revealed by US intelligence whistleblower Edward Snowden. The US eavesdropping targeted her staff's communications and those of others at Petrobras, the state oil giant.
US National Security Agency snooping so infuriated her that she canceled a state visit to Washington scheduled for October in protest, and pushed for a UN resolution aimed at protecting "online" human rights.
The trove of documents leaked by Snowden - who now lives in Russia - sparked outrage in the United States and abroad about the vast capabilities of America's intelligence programs.
Following the revelations, US President Barack Obama was forced to propose changes to the electronic surveillance of US citizens, including proposals put forward in March to take bulk phone data collection out of the hands of the NSA.For the latest tech news and reviews, follow Gadgets 360 on X, Facebook, WhatsApp, Threads and Google News. For the latest videos on gadgets and tech, subscribe to our YouTube channel. If you want to know everything about top influencers, follow our in-house Who'sThat360 on Instagram and YouTube.