(Adds comment from defence ministry, Heckler & Koch)

FRANKFURT, Sept 2 (Reuters) - A German court ruled on Friday that the government has no right to compensation from Heckler & Koch IPO-HIK.L for what Berlin has said were faulty assault rifles, handing a victory to the gunmaker.

Berlin has said that the G36 rifle, which is standard issue for militaries across the globe and has been used by the German army for nearly 20 years, does not shoot straight in hot weather or when it heats up through constant firing.

The first suggestions that the gun might be faulty date back to April 2010, when 32 Bundeswehr paratroopers were ambushed by Taliban fighters in northern Afghanistan. Three German soldiers were killed in a nine-hour firefight. The G36 was reported to have overheated, forcing the Germans to retreat.

Berlin, which has bought about 180,000 of the rifles since 1996, eventually decided to replace the G36 as the German army’s standard rifle from 2019 and sought compensation for some rifles it had received from Heckler & Koch.

Heckler & Koch said the rifles it had delivered complied with the specifications agreed with the government in 1996.

While the court did not comment in its ruling on whether the rifles shoot straight when they heat up, it said that they met the specifications set out in the purchase contracts. The rifles had also passed the quality and acceptance testing laid out in the contracts, it said.

The court had said in a June hearing that it was leaning towards backing Heckler & Koch because the government had, over the years, ordered rifles with the same specifications as in 1996 even though they were required for different environments

Germany’s defence ministry said it would appeal against Friday’s ruling, depending on the reasons given by the court.

“If the court bases today’s decision on the same dubious arguments as it gave before the summer, then the relevant government office will appeal,” a ministry spokesman said.

Heckler & Koch said it would not comment on the actions of its customers but affirmed that it plans to take part in the government’s tender for a new supply contract, expected to be awarded in 2018.

“We make the world’s best assault rifle. Many armies in the western world use our weapons. We are already looking forward to the German army’s assault rifle tender, in which we will again prove our performance,” the company said in a statement. (Reporting by Maria Sheahan; Additional reporting by Victoria Bryan and Ilona Wissenbach; Editing by David Goodman)