BERLIN—Germany is considering purchasing 45 Boeing Co.-made F/A-18 warplanes for its air force, German government officials said Thursday, in what would be a win for the Trump administration but a surprise blow to Boeing rival Lockheed Martin Corp.

Lockheed Martin, which makes the more advanced F-35 jet, had hoped to clinch the German order and the U.S. had lobbied for Berlin to purchase the airplane. But German officials said the Boeing-made F/A-18 was more cost-efficient.

“We...