Plans for new anti-terrorism controls on websites have led to a government defeat in the Lords - by just one vote.
The Terror Bill was put together after the July bombings
The original plans would have allowed a police constable to decide that information on the internet could be related to terrorism.
But peers changed the Terrorism Bill to ensure police have to ask judges before telling internet providers that web pages should be removed.
The bill received a third reading and will now return to the Commons.
The government was defeated by 148 votes to 147 in the vote on plans to give police powers to curb unlawful terrorism-related material on the internet.
Home Office officials said minister Baroness Scotland was away for the vote because of a family emergency.
Peers threw out plans for a new offence of "glorifying" acts of terrorism when the bill came before the Lords last month.
Ministers have said they will try to overturn this defeat.
The government also faced defeat when peers voted to redraft ministers' version of the offence of "intentionally" or "recklessly" disseminating a terrorist publication.