A spokesman said his move was made in response to a request from the Metropolitan Police, who have been engaged in a year-long inquiry into claims that peerages were offered in return for financial support for political parties.
The spokesman said that police were concerned that the disclosure of information in the story could harm their inquiry. The BBC last night insisted its report was a "legitimate matter of public interest" and opposition politicians claimed the move could be a government cover-up.
The BBC said the injunction was granted after a two-hour hearing involving lawyers from both sides at the Royal Courts of Justice in London, about an hour before the first planned broadcast of the story on BBC1's 10 O'Clock News.
Lord Goldsmith - a member of the Cabinet - was acting independently of the government in seeking the injunction, his spokesman stressed.
"The application for an injunction was made by the Attorney-General this afternoon at the specific request of and in co-operation with the police, because of their concern that disclosure of certain information at this stage would impede their inquiries," he said.
"The Attorney-General acted completely independently of government and in his independent public-interest capacity."
A Downing Street source said the first No 10 knew of the matter was when they saw the 10 O'Clock News.
The Metropolitan Police gave a statement identical to that of the Attorney-General's office.
Sir Menzies Campbell, the Liberal Democrat leader, said
the implication of Lord Goldsmith's actions was that "he at least contemplates the possibility that a prosecution will follow".
He added: "This is all pretty sensitive territory and we have to be very careful about speculating beyond the facts that are presently available."
However Sir Menzies' chief of staff, Edward Davey, MP, said: "It may be that this injunction was needed to protect the integrity of an ongoing police investigation.
Yet the fact that the BBC felt that it was in the public interest suggests that we may be looking at yet another example of government cover-up."
The cash-for-honours inquiry was sparked in March last year by complaints to the Metropolitan Police by Scottish National Party and Plaid Cymru MPs that honours appeared to have been offered in return for financial support to the major parties.
Inquiries have focused on loans totalling tens of millions of pounds for the Labour and Conservative campaigns for the 2005 General Election.
Four people have been arrested - Tony Blair's personal fund-raiser Lord Levy, Downing Street aide Ruth Turner; Labour donor Sir Christopher Evans and former headteacher Des Smith - but there have been no charges.
Mr Blair has been interviewed twice by police, as a witness. He has not been arrested or interviewed under caution.
Yesterday's hearing is understood to be the first time that an injunction has been sought or granted in the affair.
Angus McNeil, the SNP MP whose complaint triggered the investigation, said: "It would appear that the police may have significant information that don't want to be made public at this stage."