UK government arms sales to Saudi Arabia are lawful, the High Court has ruled, after seeing secret evidence.
The court rejected campaigners' claims ministers were acting illegally by not suspending weapon sales to the kingdom, which is fighting a war in Yemen.
The UN claims strikes on Houthi rebels caused thousands of civilian deaths.
The government said defence exports would continue to be reviewed but the Campaign Against the Arms Trade said an appeal against the ruling was planned.
The group had claimed the UK has contravened humanitarian law, and it attacked the refusal of the Secretary of State for International Trade to suspend export licences for the sale or transfer of arms and military equipment.
Lord Justice Burnett and Mr Justice Haddon-Cave, sitting in London, said the decision to carry on the arms trade was not unlawful.
The judges said "closed material", which had not been made public for national security reasons, "provides valuable additional support for the conclusion that the decisions taken by the secretary of state not to suspend or cancel arms sales to Saudi Arabia were rational".
Equipment sold to Saudi Arabia includes Typhoon and Tornado fighter jets, as well as precision-guided bombs.
The sales contribute to thousands of engineering jobs in the UK, and have provided billions of pounds of revenue for the British arms trade.
Saudi Arabia has been supporting Yemen's internationally-recognised government after a civil war broke out in 2015.
Houthi rebels, loyal to deposed president Ali Abdullah Saleh, began an attack in 2014, forcing leader Abdrabbuh Mansour Hadi to flee the country for a time.
Since then the Saudi kingdom, and eight other mostly Sunni Arab states, have supported an air campaign aimed at restoring Mr Hadi's government.
Andrew Smith, of Campaign Against Arms Trade, said: "This is a very disappointing verdict, and we are pursuing an appeal.
"If this verdict is upheld then it will be seen as a green light for government to continue arming and supporting brutal dictatorships and human rights abusers like Saudi Arabia that have shown a blatant disregard for international humanitarian law.
"Every day we are hearing new and horrifying stories about the humanitarian crisis that has been inflicted on the people of Yemen."
Rosa Curling, of law firm Leigh Day, which represented the campaign group, said: "Nothing in the open evidence, presented by the UK government to the court, suggests this risk does not exist in relation to arms to Saudi Arabia.
"Indeed, all the evidence we have seen from Yemen suggests the opposite: the risk is very real. You need only look at the devastating reality of the situation there."
James Lynch, Amnesty International's head of arms control and human rights, said the ruling was "deeply disappointing".
"Irrespective of this ruling, the UK and other governments should end their shameless arms supplies to Saudi Arabia," he said.
"They may amount to lucrative trade deals, but the UK risks aiding and abetting these terrible crimes."
The government said UK defence exports would continue to be "under careful review" to ensure they meet the standards of the Consolidated EU and National Arms Export Licensing Criteria.
"We welcome this judgment, which underscores the fact that the UK operates one of the most robust export control regimes in the world," a spokesperson said.