The motion on student funding passed narrowly with majority of 21, with six Tories and 21 Lib Dems rebelling Press Association

Protesters clashed with police in London tonight after the coalition won the vote to increase tuition fees for students in England to up to £9,000 per year.

The plans faced bitter criticism not only from Labour MPs but from Lib Dem and Tory backbenchers, but the move was carried by 323 votes to 302 in what has proved to be the most testing parliamentary vote to date for the coalition government.

The result narrowed the coalition government's notional majority of 84 to 21, in a vote which took place as thousands of protesters opposed to the rise in fees clashed with police in the streets outside parliament.

Police entered Parliament Square tonight to stop protesting students from vandalising the Treasury building. A number of students started using concrete blocks and metal poles to smash windows of the building on Great George Street while being contained inside the square.

Prince Charles and Camilla, Duchess of Cornwall, were "unharmed" after the car they were travelling in was attacked during the protest, a Clarence House spokeswoman said tonight.

Officers with riot shields and helmets charged at the protesters as tensions ran high after news of the government's victory in the vote spread through the crowd.

Students had already sprayed graffiti onto the building and continued to vent their anger into the evening.

The vote to raise the tuition fees ceiling in England from £3,290 to a maximum of £9,000 led to the resignation of two ministerial aides – Mike Crockart and Jenny Willott. Two former Lib Dem leaders, Charles Kennedy and Sir Menzies Campbell, were among the 21 Lib Dem MPs who rebelled against the government proposals .

Tim Farron, the party president, also voted against. Simon Hughes, the deputy leader, was among the eight Lib Dems who abstained, though this figure included two who were at the climate change summit in Cancún, Mexico. Chris Huhne, the climate change secretary, would have backed the government, and Martin Horwood would have voted against the change. Six Tories rebelled, among them David Davis, a standard-bearer for the right. Tory MP Lee Scott resigned as Philip Hammond's parliamentary private secretary. He abstained in the vote.

Cable insisted tonight that the party would "go forward" and described the party's internal disagreement on the issue as having been "respectful" at all times.

Speaking after the vote, Cable said: "We have taken different views on this issue, but the party remains united. We will go forward. We are committed to making the coalition government work and I feel positive. It's been a difficult day, and a difficult decision. The whole point of being in government is that you have to make tough choices."

He admitted there was a "big job to be done" in getting the message out that the government had to put universities on a sound financial footing, and that it had been done in a way that was fair.

"I think people when they reflect on the detail of what we have done will realise that we have produced a package in very difficult circumstances when we had to make cuts which is more progressive and it will help low income graduates, and it will help part-timers and it's very much in the long term interest of universities."

Ed Milband, the Labour party leader, said tonight's vote was "disappointing" for young people in the country.

Politics was at an "even lower ebb" as a result of tonight's vote, he said.

"What really concerns me is the impact this will have on social mobility and people getting on in our society," said Miliband, who voted that his party would campaign for "educational opportunity".

Aaron Porter, president of the National Union of Students, said the union had won over public opinion. The measure was passed "only because MPs have broken their promises", he said.

"We are incredibly disappointed and angry with the politicians who have let us down so badly. They have voted for a policy they know is unfair, unnecessary and wrong."

Tonight's vote followed five hours of debate that began rowdily as Labour MPs barracked Vince Cable, the Lib Dem business secretary, as he insisted that the controversial plans to treble the cap on tuition fees were "progressive".

Cable said the tuition fee rise was a central part of a policy that he said was designed to "maintain high quality universities in the long term, tackle the fiscal deficit and provide a more progressive system of graduate contributions based on people's ability to pay".

Earlier in the afternoon, the shadow business secretary, John Denham, warned Lib Dems that backing for the proposals would forfeit the party's right to call themselves "a progressive party". He said the plans would see English students facing higher fees than students in any other public universities in the developed world.

All 57 Lib Dem MPs said before the election that they would oppose any rise in tuition fees although the coalition deal included an agreement to allow them to abstain in any vote on the issue.

Nick Clegg, the party leader, had ensured that all 17 Lib Dem ministers in the Commons would vote for the increase in tuition fees, and had hoped that another dozen backbench MPs would join him in what he had previously described as "going through the fire".

Among the rebels was Mike Crockart, Lib Dem MP for Edinburgh West, who this afternoon quit as private parliamentary secretary to the Scottish secretary, Michael Moore, to oppose the government.

In a letter to the deputy chief whip, Crockart said he could not vote for a system "which I believe puts barriers in the path of able students".

Crockart tendered his resignation despite the fact that Clegg had sought to win over doubters by giving ministerial aides permission to abstain from the vote this evening without fear of punishment.

Jenny Willott, Lib Dem MP for Cardiff Central, also resigned as PPS to Chris Huhne in order to vote against the plans.

As protesting students and academics amassed outside parliament Cable acknowledged the "very strong feelings inside and outside the house" aroused by the proposals but defended the policy as the best option on the table.

He highlighted three last-minute concessions made yesterday by the business department covering scholarships, part-time students and the £21,000 repayment threshold, to make the system as fair as possible.

But in a rowdy Commons atmosphere, Labour MPs, as well as some Lib Dems and Conservatives, challenged claims that the rise was progressive for students.