The Law Lords voted 5-0 in favour of the SFO appeal.
One of them, Baroness Hale, said she would have liked to have been able to uphold the court's decision that the SFO's director acted unlawfully because it was "extremely distasteful that an independent public official should feel himself obliged to give way to threats of any sort".
Despite this, she said: "I agree that [the director's] decision was lawful."
Another, Lord Bingham, said the SFO director Robert Wardle "was confronted by an ugly and obviously unwelcome threat".
But he asserted that whether his decision was right or wrong was not at issue, rather whether it was one he was lawfully entitled to make. The House of Lords decided that it was.
Meanwhile the new director of the SFO, Richard Alderman, told The World at One on Radio 4 that the ruling would not stop it from pursuing other investigations.
"What we've got to do is to look at what's being said and look and do the balancing that the House of Lords are talking about and approach it in the light of the guidance that the House of Lords have given to us.
"I regard this as being an extreme circumstance, an extreme case.
"From my point of view, we've got a number of other cases and I'm very determined that we pursue those as vigorously as possible."
ARMS DEAL DIARY
1985: Defence Secretary Michael Heseltine signs the al-Yamamah deal with the Saudi government
May 2004: Allegations of a BAE slush fund published by the Guardian newspaper
November 2004: SFO investigation begins
December 2006: SFO discontinues its inquiry
April 2008: High Court rules that SFO acted 'unlawfully'
July 2008: House of Lords overturns the High Court decision
Campaign group Justice said the Law Lords had delivered "a disappointingly narrow judgement".
"It is a sad day for the rule of law when a senior prosecutor bows to threats from a foreign government and our most senior judges will do nothing to stop it," said Justice's director of human rights policy Eric Metcalfe.
Corner House, which was one of the groups which campaigned for the initial judicial review of the decision, said it was also "very disappointed".
But it defended its campaign to bring the case to court, saying a large amount of information on how decisions related to national security were made had been brought into the public domain.
This would otherwise have not been brought to light, Corner House's Susan Hawley told the BBC News website.
The al-Yamamah deal with Saudi Arabia was first signed in 1985 but ran into the 1990s and involved BAE selling Tornado and Hawk jets, other weapons and long-running maintenance and training contracts.
BAE was accused of illegal payments to Saudi officials, but the defence company has always maintained it acted lawfully.
In December 2006, the then Attorney General, Lord Goldsmith, announced that the SFO was suspending its inquiry into the deal, saying it would have caused "serious damage" to UK-Saudi relations and, in turn, threatened national security.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.