Brazil's congress will vote next week on a controversial new internet bill that will help to define the parameters of President Dilma Rousseff's campaign to reform the web.

It is the first legislative step in a major diplomatic and technological push by Brazil to increase domestic cyber-security, reduce reliance on US servers and revise global governance of the internet in the wake of the NSA spying revelations.

The marco civil da internet – or civil rights framework for the internet – has been in the pipeline for more than a year, but it was fast-tracked by Rousseff in September after leaked documents from NSA whistleblower Edward Snowden revealed the US agency had been monitoring the president's emails and phone calls, those of Brazil's biggest oil company and the communications of millions of citizens.

Officials are haggling with legislators and telecom companies over last-minute amendments to the bill, which will only apply domestically but is likely to set several fundamental principles for the government's international strategy

The marco civil was primarily intended to enshrine the rights of Brazil's fast-growing community of internet users with provisions for net neutrality, privacy protection, open government, data storage guidelines and guarantees that platform providers should not be held liable for user content.

But, since the NSA scandal broke, the government has also pressed for an amendment that would oblige Facebook, Google and other foreign service providers to base servers inside Brazil.

This has proved controversial. Critics say such a step would reduce efficiency and could lead to protectionism and a fragmentation of the internet.

Progress on the marco civil has also been held up by a dispute over net neutrality, under which internet providers are supposed to treat and set charges for all data equally. Telecom companies are arguing for more scope on pricing but the government says the spying revelations make this too urgent to leave much longer.

"We cannot turn our backs because it is controversial. This is particularly the case since the allegations of espionage," said the leader of the ruling party in the lower house, José Guimarães. "This bill will not solve the problem, but it is a first step. We must develop a new framework for a civil internet, with rights and duties."

The debate on the marco civil is scheduled to begin on Tuesday. It is only a small part of the plans to make Brazil's communications less vulnerable.

Rousseff, who is facing an election next year, has made internet security one of her priorities.

After the spying scandal broke in September, she called on the United Nations to revise internet governance and outlined her nation's policy of "cyber neutrality". To further the debate, Rousseff announced an international conference on the subject which will be held in Rio de Janeiro early next year.

"The current model of internet governance must evolve and requires institutional changes to ensure an internet that is stable, safe, transparent and democratic," Brazil's communications ministry told the Guardian by email.

Along with the diplomacy, Brazil is developing its own software and beefing up its hardware. Two weeks ago, Rousseff confirmed plans for a more secure email service via her twitter account , saying the move was necessary to "prevent possible espionage".

The federal data processing service (Serpro, by its Brazilian acronym) is developing the system and will be the sole provider of email services for public officials.

"This means that messages exchanged within the government network will be protected from external breaches since they do not fall into the open email network," the communications ministry said.

The proposed email service -– which was in the pipeline before the spying scandal, but has been accelerated as a result – will be available to the entire population, though it is unlikely to supplant the current market leader, gmail.

The government is also upgrading and expanding the country's communications infrastructure to reduce its reliance on US data centres. Currently, the bulk of internet and telephone data in Latin America passes through a single building in Miami, known as the network access point of the Americas.

Brazil is trying to divert more of its traffic elsewhere. In recent years, it has laid fibre-optic submarine cables to Angola, which would strengthen direct links with African telecommunications hubs, and other cables are planned to Nigeria and other BRICS nations, which also include Russia, India, China and South Africa). (the countries' intials makign the acronym). Brazil is also negotiating a 10,000km "optical ring" that would directly link communications between 12 South American countries and Europe.

Some of the changes could affect the core infrastructure of the web.

"I think what is at stake is to have more root servers in Brazil and elsewhere in Latin America," said Ronaldo Lemos, director of the Institute of Technology and Society of Rio de Janeiro. "There are currently root servers in the US, Europe and Sweden, with backups in Iceland, Spain and Australia. But they are not that well distributed." Speculation that the president may be lobbying to host root servers in Brazil increased last month when Rousseff met Fadi Chehade, the president of the internet's governing body, Icann (the internet corporation for assigned names and numbers).

The meeting with Icann – which is made up of representatives from private industry, national governments and civil society groups – appeared to be a departure from Brazil's previously stated policy, which was for the United Nations to take greater control of internet.

Lemos said the president seemed to realise that it was better to diversify control than put an intergovernmental body in charge of the web.

"Dilma seems to be moving more towards a multi-stakeholder approach. I think that is a good change," he said.

The marco civil could send a different signal. Although the bill has still not been finalised, Lemos, who drafted the original framework, is opposed to amendments that would force foreign companies to store data in Brazil. Although these moves are designed to protect local users from having their data intercepted in the US, Lemos said such steps could lead to the internet becoming less efficient and more influenced by protectionist sentiment.

Other critics go further, warning that some of the proposed changes could lead to a partitioned internet.

Lemos, however, says Brazil's policy is positive. "Brazil is not moving away from the internet," he said. "Putting in place new cables between BRICs and between Latin American countries, and buildings more internet exchange points reinforces the ideal of an open internet without a core."

Many of Brazil's steps have been touted for years and were primarily driven by economic imperatives rather than security concerns. But the scandals have created an ideal political climate for them to be accelerated.

"Given the country's fast-growing digital environment, Brazil's proposal to build more internet exchange points and lay extra fibre-optic cable is long overdue," said Robert Muggah of the Rio de Janeiro-based Igarapé Institute. "At the moment, there is both the political and technical capability to do so."

Jonatas Lucena, a São Paulo-based lawyer who specialises in virtual crime, said Brazil was still a long way from ending its reliance on US technology and talent. "Today, we buy everything related to IT from the United States and we stand in the hands of its developers and, in turn, in the hands of the NSA."

The marco civil will not change that, but it will be a marker of the direction Brazil wants to take in its search for internet security and profits.