The House of Lords had proposed putting a legal duty on water firms to reduce untreated sewage discharges.
Ministers rejected the amendment, but following pressure from peers and campaigners, the government put forward its own alternative.
MPs and peers have now voted for the plan but some say it is not enough.
Green peer Jenny Jones argued that the government's amendment did not include proper timetables or targets for companies to reduce sewage discharge.
"This will come to haunt MPs," she said, and warned that the UK risked returning to "the 1970s version of ourselves as the dirty man of Europe".
But the Duke of Wellington - who originally proposed the amendment to tackle the problem - was satisfied, arguing that the bill now gave ministers the power to act against poorly performing companies.
He said pollution of the country's rivers was "a national embarrassment… our children and grandchildren will surely be surprised that we allowed this revolting state of affairs to continue for as long as it did".
"I hope these clauses will bring it to an end."
Water companies are allowed to release sewage into rivers after certain weather events, such as prolonged periods of heavy rain.
This protects properties from flooding and prevents sewage from backing up into streets and homes.
However, Environment Agency figures show that water companies discharged raw sewage into rivers in England more than 400,000 times last year, with untreated effluent - including human waste, wet wipes and condoms - released into waterways for more than three million hours in 2020.
Some firms are taking action - Southern Water has announced that it is launching a taskforce to cut storm overflows by 80% by 2030 - but there was no law to force them to.
In October, the Duke of Wellington - an independent peer - put forward an amendment to the government's Environment Bill in an effort to address the problem.
It placed a legal duty on water companies and the government to demonstrate progressive reductions in discharges of untreated sewage and to "take all reasonable steps" to avoid using combined sewer overflows.
His proposals were voted down by Conservative MPs prompting an angry response from some environmental campaigners.
In response, the government backtracked and proposed its own amendment, telling water companies they "must secure a progressive reduction in the adverse harm" caused by sewage dumps.
Environment minister Lord Goldsmith told peers that "water companies face a choice: reduce sewage discharges or face the consequences of strong enforcement action".
Liberal Democrat peer Baroness Parminter noted the intense interest in the bill - particularly on social media - and said "this government can be under no illusion - if they do not listen and act to stop these appalling sewage discharges, the public will notice".
"It won't just be the environment paying the price in the future, the government will pay the price."
Labour's Baroness Hayman said the government needed to make sure penalties were meaningful in order to ensure companies "change their behaviour".
At the end of the debate, peers voted through the Environment Bill - which was first introduced to Parliament in January 2020 - and will now become law.