A US federal appeals court has thrown out a lawsuit by the families of two Yemeni men allegedly killed as innocent bystanders in a US drone strike in 2012.

The unanimous ruling by a three-judge panel of the US court of appeals for the District of Columbia circuit in Washington upheld a lower court’s finding that it lacked the authority to question decision-making by the government over the missile strike.

The case began in 2015 when the families of Salem bin Ali Jaber, an imam, and Waleed bin Ali Jaber, a police officer, filed a “wrongful death” suit against the US government, Barack Obama and other US officials.

They claimed the deaths were collateral damage in an August, 2012, Hellfire missile attack by a US drone in the eastern Yemeni village of Khashamir targeting three extremists, court papers said.

Salem had recently preached against al-Qaida and brought Waleed, his nephew, along for protection to a meeting requested by the three, the papers said. All five men were killed in the strike.

The families sought a court declaration that the strike violated international and US law. The lawsuit did not seek monetary relief.

The United States has been conducting counter-terrorism operations in Yemen for years against militant groups such as al-Qaida. In 2013, Obama set tighter rules on drone strikes and promised greater transparency.

Monday’s ruling tossing the suit said that, based on legal precedent, judges cannot second-guess the government’s military judgment. It is “the executive, and not a panel of the DC circuit, who commands our armed forces and determines our nation’s foreign policy”, the ruling said.

The circuit judge Janice Rogers Brown, who wrote the decision, also issued a rare separate opinion calling for greater oversight over the drone program.

She said the legal doctrine preventing courts from reviewing the decision-making by the president and Congress in foreign policy or national security matters may be “deeply flawed” because it blocks any court supervision of the use of sophisticated new military technologies such as drones.

“Of course, this begs the question: if judges will not check this outsized power, then who will?” said Brown, who was appointed to the appeals court bench by George W Bush. She called congressional oversight “a joke – and a bad one at that”.

The other two judges on the panel, both appointed by Obama, did not join her separate opinion.

