The High Court has ruled that the Serious Fraud Office (SFO) acted unlawfully by dropping a corruption inquiry into a £43bn Saudi arms deal.
In a hard-hitting ruling, two High Court judges described the SFO's decision as an "outrage".
Defence firm BAE was accused of making illegal payments to Saudi officials to secure contracts, but the firm maintains that it acted lawfully.
The SFO said national security would have been undermined by the inquiry.
The legal challenge had been made by Corner House and the Campaign Against Arms Trade (CAAT).
'Failure of government'
In handing down the decision on Thursday, one of the judges, Lord Justice Moses, told the High Court that the SFO and the government had given into "blatant threats" that Saudi co-operation in the fight against terror would end unless the probe into corruption was halted.
He added that the SFO had failed to assure them that everything had been done to meet the rule of law.
"No one, whether within this country or outside, is entitled to interfere with the course of our justice," he said.
"It is the failure of government and the defendant to bear that essential principle in mind that justifies the intervention of this court."
CAAT had argued that the SFO's decision to drop the probe was illegal under the Organisation for Economic Co-operation and Development's (OECD's) Anti-Bribery Convention.
"We are delighted," said CAAT's Symon Hill after the decision.
"It has been clear from the start that the dropping of the investigation was about neither national security nor jobs. It was due to the influence of BAE and Saudi princes over the UK government."
Susan Hawley of Corner House said: "This is a great day for British justice. The judges have stood up for the right of independent prosecutors not to be subjected to political pressure."
Following the judgement, BAE said: "The case was between two campaign groups and the director of the SFO. It concerned the legality of a decision made by the director of the SFO.
"BAE Systems played no part in that decision."
For its part, the Serious Fraud Office said it had no further comment, but was "carefully" considering the implications of the judgement. It could appeal to the House of Lords.
Downing Street refused to comment.
The inquiry was opened in 2004 and dropped in 2006 amid controversy
The Conservatives said the High Court's ruling was "extremely troubling".
A party spokesman said: "We were told, and Parliament was told, that national security was the reason for dropping this prosecution.
"The government has failed to persuade the court that this was the true reason.
"Gordon Brown must now decide whether to appeal - or, if not, to make a statement to Parliament on the matter."
Liberal Democrat leader Nick Clegg told BBC Two's Newsnight programme that national security had been used as a "magic wand" solution by Tony Blair and the government to absolve itself.
He said: "I find that absolutely astonishing, that we should simply accept that due process should be suspended, that a fraud investigation into allegations of massive bribery and corruption should be suspended, because the Saudi individuals want their privacy protected."
Mr Clegg said there was a "pressing need" for a full inquiry into the SFO's decision.
However, Conservative former foreign secretary Sir Malcolm Rifkind told the programme: "There have to be circumstances where the national security of this country becomes the priority for the government and which leads to a prosecution being suspended."
The SFO's inquiry was into the al-Yamamah deal with Saudi Arabia, which was first signed in 1985 but ran into the 1990s.
Under the agreement, BAE sold Saudi Arabia Tornado and Hawk jets and other assorted weapons. The deal also included long-running maintenance and training contracts.
In December 2006, the then Attorney General, Lord Goldsmith, announced that the SFO was suspending its inquiry.
Lord Goldsmith said its continuation would have caused "serious damage" to UK-Saudi relations and, in turn, threatened national security.
Saudi Arabia is also reported to have threatened to cancel last year's deal to buy 72 Eurofighter Typhoon jets from BAE Systems.
Worth an initial £4.4bn, contracts for maintenance and training are expected to take the final bill to £20bn.
BAE argued that the SFO probe could "jeopardise" both this deal and "seriously affect" relations with the Saudi kingdom.
Details of the alleged bribes to Saudi officials were revealed in June of last year in an investigation by the BBC's Panorama programme.
It said that up to £120m a year was sent by BAE Systems from the UK into two Saudi embassy accounts in Washington.
Panorama established that these accounts were actually a conduit to Saudi Prince Bandar for his role in securing the al-Yamamah deal, something he has strongly denied.
The OECD said last month that it was launching its own investigation into the decision to drop the SFO inquiry.