Nick Clegg was tonight forced to clarify his position on the Iraq war after he stood up at the dispatch box of the House of Commons and pronounced the invasion illegal.

The deputy prime minister insisted he was speaking in a personal capacity, as a leading international lawyer warned that the statement by a government minister in such a formal setting could increase the chances of charges against Britain in international courts.

Philippe Sands, professor of law at University College London, said: "A public statement by a government minister in parliament as to the legal situation would be a statement that an international court would be interested in, in forming a view as to whether or not the war was lawful."

The warning came after a faltering performance by Clegg in the Commons when he stood in for David Cameron at prime minister's questions. The deputy prime minister made an initial mistake when he announced that the government would close the Yarl's Wood centre as it ends the detention of children awaiting deportation. The Home Office was forced to issue a statement saying that the family unit at Yarl's Wood would close but that the rest of the centre would remain open.

Shortly before that slip-up, Clegg threw the government's position concerning the legality of the Iraq war into confusion when, at the end of heated exchanges with Jack Straw, foreign secretary at the time of the war, Clegg said: "We may have to wait for his memoirs, but perhaps one day he will account for his role in the most disastrous decision of all: the illegal invasion of Iraq."

Clegg's remarks could be legally significant because he was standing at the government dispatch box in the Commons.

Downing Street played down the significance of the remarks by issuing a statement saying that he was expressing his "long-held view" about the Iraq conflict. In an attempt to avoid speculation about splits with Cameron, who voted in favour of the war, Downing Street added that the government would await the findings of the Chilcot inquiry before reaching a view on the war.

"The coalition government has not expressed a view on the legality or otherwise of the Iraq conflict," the No 10 spokesman said. "But that does not mean that individual members of the government should not express their individual views. These are long-held views of the deputy prime minister.

"The Iraq inquiry is currently examining many issues surrounding the UK's involvement in Iraq, including the legal basis of the war. The government looks forward to receiving the inquiry's conclusions."

But this appeared to be contradicted by the Chilcot inquiry, which issued a statement saying it was examining the legal issues in the run-up to the war but would not make a judgment about the legality of the war. A spokesman said: "The inquiry is not a court of law, and no one is on trial."

The government also faced a challenge in explaining an apparently new constitutional convention that the second most senior member of the cabinet is now free to stand at the dispatch box and express opinions of his own that do not reflect government policy.

Asked whether Clegg had been speaking as the leader of the Liberal Democrats and not as deputy prime minister, a Downing Street spokeswoman said: "Yes."

Asked how MPs could establish in future whether Clegg is speaking as deputy prime minister or as leader of the Liberal Democrats, the spokeswoman said: "The deputy prime minister is entitled to express his own view at the dispatch box."

The Lib Dems were keen to play down the significance of Clegg's remarks. But it is understood that the Lib Dem leader feels freer to speak out against the alleged illegality of the Iraq war after the recent publication of previously classified documents by the Chilcot inquiry.

Sir Gus O'Donnell, the cabinet secretary, wrote to Sir John Chilcot on 25 June to allow the inquiry to publish more documents relating to the legal advice. The most significant of these documents was a note on 30 January 2003 by the then attorney general, Lord Goldsmith, to Tony Blair.

In the note Goldsmith wrote: "I remain of the view that the correct legal interpretation of [UN security council] resolution 1441 is that it does not authorise the use of military force without a further determination by the security council."

Goldsmith famously changed his mind on the legality of the war in March 2003 after Admiral Sir Michael Boyce, the former chief of the defence staff, demanded a clear undertaking that military action would be lawful. Boyce feared that British forces could face legal action unless the invasion had legal cover.

On 7 March 2003, after visiting Washington, Goldsmith told Blair that a new UN resolution may not be necessary, although invading Iraq without one could lead to Britain being indicted before an international court. Ten days later Goldsmith ruled that an invasion would be lawful.

Sands said: "Lord Goldsmith never gave a written advice that the war was lawful. Nick Clegg is only repeating what Lord Goldsmith told Tony Blair on 30 January 2003: that without a further UN security resolution the war would be illegal and Jack Straw knows that."