Saudi Arabia is said to have threatened to cancel a Eurofighter order
The Serious Fraud Office (SFO) has argued that it did not act unlawfully when it halted its investigation into a £43bn Saudi arms deal.
It is appealing against a High Court ruling that the decision to end the corruption inquiry in the face of Saudi threats was unlawful.
Saudi Arabia had threatened to withdraw cooperation on counter-terrorism issues if the inquiry had continued.
The SFO said national security would have been "damaged" by proceeding.
Jonathan Sumption QC, representing the SFO, told the Law Lords that "the critical issue was whether a prosecutor may not comply with a demand which has been supported by threats".
He argued that it was not the threat itself which was critical to the SFO Director's thinking, but its impact on national security if it were carried out.
Mr Sumption said prosecutions were routinely abandoned if not thought to be in the public interest - for example, if they were to reveal the identity of a mole or hidden source.
And there was no clear line when deciding what was in the public interest, he said.
The SFO's then-director, Robert Wardle, had shown "a healthy and proper degree of scepticism" when initially told of the threat to national security, Mr Sumption said, adding the decision to discontinue the investigation went "against his every instinct as a prosecutor".
However Mr Wardle had felt that national security could be "severely damaged" by proceeding with the probe, Mr Sumption told the court.
The inquiry had centred on allegations - strongly denied - that BAE Systems used illegal payments when doing business with Saudi officials.
At the centre of the investigation was the giant £43bn al-Yamamah deal which involved selling Tornado and Hawk jets, other weapons and long-running maintenance and training contracts to Saudi Arabia.
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.
The High Court ruled in April this year that the SFO director's decision to end the investigation represented an "abject surrender" to pressure from a foreign government.
According to the Campaign Against Arms Trade and the Corner House, who had both campaigned for a judicial review of the decision, the director of the SFO had failed to convince the court that he had done all in his power to resist the Saudi threat and uphold the rule of law.
They believe the SFO's appeal will be unsuccessful.
"We remain confident of the strength of our case in the House of Lords. The principle that no one is above the law is fundamental to justice," said Nicholas Hildyard of the Corner House.
The appeal will be heard by the Appellate Committee of the House of Lords and the hearing is expected to last two days.