Controversial plans for new anti-terrorism laws have suffered two defeats in the House of Lords.
The Terror Bill was put together after the July bombings
Peers voted to ditch plans in the Terrorism Bill for a new offence of "glorifying" terror.
And they insisted on new safeguards on laws designed to stop the spread of terrorist publications.
Lord Lloyd of Berwick, an ex-law lord, said the glorification offence could put free speech at risk. Ministers will now ask MPs to reinstate the measure.
They stress that Labour's manifesto promised the glorification law - by convention, peers do not throw out manifesto commitments.
The defeats are the second time the government has been thwarted by opposition peers in two days.
On Monday peers insisted the identity cards scheme should not go ahead until there were full estimates of its costs, but the Home Office says it will press ahead with the project.
In November Tony Blair suffered his first Commons defeat as prime minister when MPs voted against plans to allow police to hold terror suspects for 90 days without charge.
Instead, it was decided 28 days - rather than the current 14 - should be the limit.
The Terrorism Bill was introduced following the London bombings of 7 July last year, in which four suicide bombers killed 52 people.
The government originally planned a separate offence outlawing glorification of terrorism but later decided to include it as part of a more general offence covering "indirect encouragement" of terrorism.
But in the report stage debate on the Terrorism Bill, Lord Lloyd said the glorification plan was still unworkable and incomprehensible.
Parliament's Joint Committee on Human Rights has also voiced concern that the offence of glorifying terrorism is "not sufficiently legally certain".
And peers voted by 270 to 144 to scrap the proposal.
Home Office Minister Hazel Blears immediately vowed to try to overturn the defeat when the plans return to the Commons.
"The government has made a commitment to the electorate to make the glorification of terrorist attacks an offence, and we intend to honour it," she said.
Ms Blears said it was unacceptable for people to be allowed to glorify terrorism and so make others more likely to make attacks.
"There are, unfortunately, young and impressionable people in our society who can all too easily be manipulated by those preaching or advocating a message of hate."
Later, the government endured a second defeat - over plans to outlaw the spreading of terrorism publications.
The Conservatives and Lib Dems pushed through an amendment designed to ensure that somebody would commit an offence only if they acted recklessly or with intent to provide the publications.
Opponents of the government's plans claim they could leave academics, librarians and shopkeepers open to prosecution.
Lady Scotland said the government's own amendment would have ensured "intent" had to be proved for people to be convicted.
She accused Tory peers of "opposition for opposition's sake" but critics said she had not answered their concerns and voted through their amendment by 234 votes to 134.
The Lords report stage of the bill will resume next week. The government wants to complete the scrutiny on 1 February.