MPs voted 284 to 259 in favour of an amendment allowing landlords an independent rent review and to buy their beer on the open market.
So-called "tied pubs" are required to buy supplies - often at high prices - from the companies that own the pubs.
Campaigners said the "historic" vote would help "secure the future of the Great British pub".
The amendment to the Small Business, Enterprise and Employment Bill was put forward by Lib Dem Greg Mulholland.
Mr Mulholland, the chairman of the all-party Parliamentary Save the Pub group, described the "tie" arrangement made between a pub and its owner as an "archaic" and "extraordinary" system.
It is thought to be the government's first defeat on one of its own bills since the 2010 election.
Ministers want to create a pubs code, aimed at helping pub landlords struggling to pay rent or beer costs.
It includes the right to request a rent review after five years.
But campaigners wanted the automatic right for pub landlords to exchange their tenancy for an independently-assessed market rent without any "tie".
In an attempt to head off a defeat on the amendment, which was signed by MPs of all parties, Business Minister Jo Swinson said the government would introduce new measures to allow pub landlords to apply for "market rent" rates from after two years, if a review found other measures in the bill had not helped them sufficiently.
But Mr Mulholland said this would be "business as usual".
He told MPs the new clause, which was backed by Labour, had been drafted by lawyers and publicans and would come in gradually, reducing the impact on the industry.
He added: "This is a reasonable gradual process that will simply bring back market forces into a sector that frankly has become grotesquely anti-competitive."
Tim Page, chief executive of the Campaign for Real Ale, said he was "delighted" that "after 10 years of our campaigning, MPs have today voted to introduce a market rent only option for licensees tied to the large pub companies - a move that will secure the future of the Great British pub".
The Federation of Small Businesses said it was "a historic day for tied publicans who look forward to a more open and competitive marketplace".
But the British Beer and Pub Association said the outcome was "hugely damaging".
Chief executive Brigid Simmonds said: "This change effectively breaks the 'beer tie', which has served Britain's unique pub industry well for nearly 400 years."
The government has been defeated in a Commons vote on the control that parent companies can exercise over pubs.