Protesters smashed windows and waved anarchist flags from the roof of the building housing the Conservative party headquarters as the fringe of a vast rally against university funding cuts turned violent.

The scale of the London protest defied expectations, with an estimated 50,000 turning out to vent their anger at government plans to raise tuition fees while cutting the state grant for university teaching.

Protesters who broke off from the main route of the march occupied the lobby of the building at 30 Millbank, in central London, where police wielding batons clashed with a crowd hurling placard sticks, eggs and bottles.

Activists who had masked their faces with scarves traded punches with police to chants of "Tory scum". The exchanges were recorded by broadcasters' helicopter-mounted cameras and protesters' mobile phones.

Police said at least eight people – "a mixture of police and protesters" – had been injured, and a number had been arrested. Riot police were believed to be inside the Millbank tower, attempting to restore order.

Speaking outside New Scotland Yard, the Metropolitan police commissioner, Sir Paul Stephenson, said the force should have anticipated the level of violence "better", adding: "It is not acceptable. "It's an embarrassment for London and for us."

He said his officers would go through a "thorough operation to get full control of the building", and there would be full investigations.

The message to the protesters was that they could not get away with "that kind of behaviour in daylight on the streets of London", he said.

The vast majority of protesters were peaceful, and those at the front of the march watched videos and heard impassioned speeches against the cuts.

Footage of the deputy prime minister, Nick Clegg, promising to scrap tuition fees was greeted by abusive chants.

Clegg, who deputised for David Cameron at prime minister's questions today, came under sustained attack in the Commons over tuition fees.

Meanwhile, one student won an unexpected concession from the coalition as Cameron, on a visit to China, said raising tuition fees for UK undergraduates would mean there was less pressure to charge very high fees to overseas students.

In answer to a question from a Chinese student, the prime minister said: "In the past, we have pushed up the fees on overseas students as a way of keeping them down for domestic students.

"Yes, foreign students will still pay a significant amount of money – but we should be able to bring that growth under control."

Today's huge protest was organised by the NUS and lecturers' union the UCU. Both unions have attacked coalition plans to raise tuition fees as high as £9,000 while making 40% cuts to university teaching budgets.

The higher fees will be introduced for undergraduates from 2012 if the proposals are sanctioned by the Commons, with a vote due before Christmas.

The NUS president, Aaron Porter, today condemned the actions of "those who are here to cause trouble."

He tweeted: "Disgusted that the actions of a minority of idiots are trying to undermine 50,000 who came to make a peaceful protest."

The NUS president said the march was the biggest student demonstration in generations, telling protesters: "We're in the fight of our lives ... we face an unprecedented attack on our future before it has even begun.

"They're proposing barbaric cuts that would brutalise our colleges and universities."

This "miserable vision" would be resisted, he said, imploring students to take their protests to their constituencies and adding: "This is just the beginning ... the resistance begins here."

Protesters who attacked the Millbank building used their banners to light a bonfire in the outside forecourt. Police drafted in the Territorial Support Group riot squad.

Liberal Democrat sources indicated that the party's headquarters, in nearby Cowley Street, had not been targeted.

At PMQs, the deputy Labour leader, Harriet Harman, said she hoped Clegg would go and tell the students protesting outside parliament how "fair" the government's plan was.

The Liberal Democrats fought the election on a manifesto promising to phase out tuition fees, and the party's MPs have signed a pledge to oppose any rise. The coalition agreement allows them to abstain in a Commons vote.

Harman said: "In April, he [Clegg] said that increasing tuition fees to £7,000 a year would be a disaster. What word would he use to describe fees of £9,000?"

Clegg claimed there was "consensus" across the parties about the need to reform the system. Harman replied: "None of us agree with tuition fees of £9,000 a year."

She said the rise in fees was not part of the effort to tackle the deficit, but was instead about Clegg "going along with Tory plans to shove the cost of higher education on to students and their families".

"We all know what it's like – you are at freshers' week, you meet up with a dodgy bloke and you do things that you regret," she said.

"Isn't it true he has been led astray by the Tories? Isn't that the truth of it?"

Clegg insisted the government's plans were a "fair and progressive solution to a very difficult problem".

"The proposals we have put forward will mean that those who earn the least will pay much less than they do at the moment, those who earn the most will pay over the odds to provide a subsidy to allow people from poor backgrounds to go to university," he said.

Last month, the business secretary, Vince Cable – whose department includes universities – told the Commons the Lib Dems' pre-election pledge was "no longer feasible".

"The roads to Westminster are littered with the skidmarks of political parties changing direction," he said.