MPs have backed the government's new spending rules by 320 to 258 votes after a heated debate in the Commons.
Chancellor George Osborne said the plan, requiring governments "in normal times" to spend less than they get in tax, represented "economic sanity".
Labour voted against the Conservatives' Charter for Budget Responsibility, but 21 of their MPs abstained.
It came as shadow chancellor John McDonnell said his decision to reverse Labour's stance was "embarrassing".
The charter, an amended version of which was set out in July's Budget, passed comfortably by a majority of 62 despite being opposed by the SNP, the Lib Dems and the majority of Labour MPs.
But the BBC's political editor Laura Kuenssberg said former shadow ministers Tristram Hunt, Chis Leslie, Shabana Mahmood and Liz Kendall were among 21 MPs to have defied the leadership by abstaining while a further 16 MPs were given permission to be absent by Labour whips.
The charter would legally force future governments to run an absolute budget surplus - which involves spending less than they receive in tax revenue - when the economy is growing.
After several days of criticism of his handling of the issue, Mr McDonnell sought to explain his position, saying that while tackling the deficit was "vitally important", the charter was a "puerile political stunt" and "an instrument for imposing austerity on our community unnecessarily".
Having previously said Labour would give it its backing, Mr McDonnell informed a stormy meeting of Labour MPs on Monday that he had changed his mind - and told the party to oppose it.
'A bit of humility'
Justifying his decision in the Commons, he admitted the U-turn was politically "embarrassing" but insisted a "bit of humility among politicians does not go amiss".
However, he insisted he had changed his mind on Parliamentary tactics, not economic policy, and that by voting against the framework, Labour would "disassociate itself" from a plan that he suggested was merely cover for spending cuts and an "assault" on the welfare state.
What's George Osborne proposing?
- MPs debated whether to set up a legally-binding charter affecting how much the government can spend
- It would mean that by 2020, the government had to run a budget surplus - which means it would be spending less than it collects in taxes
- The charter would apply in "normal economic times", which would be when the economy is growing by 1% a year or more
- The Office for Budget Responsibility, an independent watchdog, will be responsible for policing the new rules
- Mr Osborne says it will make ministers more accountable, but critics warn that it is either meaningless or will bind the hands of future governments
- Watch Norman Smith explain the difference between debt and deficit
- Peston: Fiscal flip-flop
"I want to break the stranglehold that the focus on deficits has had on the economic debate in this country in recent years," he said. "Yes the deficit is vitally important but we need a paradigm shift to open up the wider debate about what makes a health economy."
The proposed rules were not "economic instruments but political weapons", he said, claiming that Mr Osborne had treated his existing budgetary framework "with contempt" and was unlikely to adhere to them.
"When the circumstances and judgement change, it is best to admit to it and change as well," he said, adding that he had been influenced by "professional advice" he had received, a change in the economic outlook and the plight of the Redcar steelworkers.
The 21 Labour MPs who abstained
- Fiona Mactaggart
- Rushanara Ali
- Ian Austin
- Ben Bradshaw: former culture secretary
- Adrian Bailey: former chair of the Commons business committee
- Shabana Mahmood: former shadow Treasury minister
- Ann Coffey
- Angela Smith
- Simon Danczuk
- Jamie Reed: former shadow home office minister
- Chris Evans
- Graham Stringer
- Frank Field: former work and pensions minister
- Gisela Stuart
- Mike Gapes: former chair of the Commons Foreign Affairs committee
- Margaret Hodge: former chair of the Commons Public Accounts committee
- Tristram Hunt: former shadow education secretary
- Graham Jones
- Helen Jones
- Liz Kendall: defeated leadership candidate and former shadow care minister
- Chris Leslie: former shadow chancellor
But Mr Osborne said the UK must "live within its means" and help equip the UK economy to withstand future economic shocks, arguing that if the UK could not manage to get control of its deficit and debt by 2019, after nine years of successive growth, when would it be able to do this.
He accused Labour of being "profligate" and wanting "to spend money we don't have and borrow for ever".
"It is not a political gimmick to have sound public finances," he said. "I tell you what is a political gimmick - coming out on the eve of your conference with some policy suggesting you support what we are doing and two weeks later turning up in the House of Commons and voting against it".
Former shadow chancellor Chris Leslie, one of those Labour MPs who abstained, told MPs that the party "should not set its face" against a surplus but said the proposal would not give Mr Osborne sufficient room for manoeuvre in the event of a downturn.
The UK has run a budget surplus in only 12 years since 1948.
Critics have dismissed the charter as a "gimmick" that will either bind the hands of future governments or have so may exemptions to be pointless - and Mr Osborne himself described similar legislation introduced by former Prime Minister Gordon Brown as "vacuous and irrelevant" in 2010.