Heckler & Koch, Germany's most infamous small arms manufacturer, is gaining plenty of experience of the inside of courtrooms.

While five of its former employees - including two ex-CEOs - are facing charges of breaching export control laws by selling guns that ended up in the arsenal of Mexico's corrupt police forces, the company is itself is entering a legal battle with the German government over whether its prestige weapon - the G36 assault rifle - shoots straight when it gets hot.

On Friday, the case is to go before a court in Koblenz, southern Germany, where the army's procurement office is situated. It is up to the judges to determine whether the G36, the German army's standard assault rifle since 1996, loses accuracy when it heats up. The company, meanwhile, is out to rescue its reputation and its prestigious relationship with the German military - built up in over 50 years of collaboration.

Some say the company has reason to feel aggrieved. "I can understand if Heckler & Koch said that this was damaging to its business and reputation - one could argue that," said Sebastian Schulte, a defence analyst and Germany correspondent for a military magazine "Jane's Defence Weekly." "In my opinion, Heckler & Koch is seeking closure of the issue and validation by the court's decision, to show that they haven't done anything wrong."

Growing doubts and bad press

H&K has supplied the German military for decades

The first doubts over the G36 were raised in 2012, when "Der Spiegel" reported that the rifle's accuracy "sank by a third at distances of over 300 meters," citing internal investigations by the Bundeswehr. While no such experiences had been encountered in battle, the news magazine went on, ISAF commanders had ordered troops to heed instructions to make sure to allow the gun's barrel to cool "after shooting the ammunition rapidly."

The company angrily defended the G36, implying that a media conspiracy was at work, but just a few weeks later, the "Bild" newspaper came across a Bundeswehr report to then Defense Minister Thomas de Maiziere, which contained the damning sentence, "All G36 rifles tested until now show an alteration in the mean target in a heated shooting condition, so that an enemy at a distance of 200 meters can no longer be safely engaged."

Several more unfriendly news stories followed in the next few years, usually involving leaked reports from official test centers, with the blame either put on the lightweight polymer used to make certain parts of the G36, or a certain brand of ammunition that heated the barrel more than others.

Tension between H&K and government

In March 2015, Defense Minister Ursula von der Leyen told a press conference that the G36 had "precision problems," to which H&K responded with a tetchy press release that said the "relevant parameters for our product are wilfully being changed."

"The fact that the requirements for a weapon change over the course of 20 years is normal," Schulte told DW. "A weapon is just a tool, like a hammer or a drill, and if the conditions on the construction site change, then you have to review the tool."

The G36 was designed in the late 80s, when its likeliest use appeared to be in Central Europe, fending off a Soviet invasion. "In other words, for a specific scenario under the climatic conditions you have in Europe," said Schulte. "If you then take the rifle to Afghanistan, as the Bundeswehr did, starting in 2002, then, of course, you have different operational and climatic conditions."

The following month came the breaking point: von der Leyen announced that all 167,000 G36s used by the Bundeswehr were to be replaced over the next few years - though she stopped short of suggesting that the military would switch brands completely.

This prompted Jürgen Grässlin, the gun activist and Heckler & Koch nemesis who exposed the illegal arms sale to Mexico, to file two more lawsuits of his own - one against defense ministers de Maiziere and von der Leyen for continuing to buy the rifle "despite knowledge of its technical flaws," and one against H&K's CEO Andreas Heeschen for hiding the rifle's defects. Both lawsuits have so far proved unsuccessful.

The gunmaker is based in the southern town of Oberndorf

A study commissioned by the German defense ministry vindicated H&K in October, establishing that, while the scientific conclusions of the tests could not be refuted, there was no evidence that German soldiers had been put in danger because of G36's accuracy issues.

Schulte is also skeptical that there was ever anything seriously wrong with the G36, beyond "individual cases" of overheating. "Besides being the Bundeswehr's standard rifle for two decades, the G36 is in use with various military and police forces of more than 40 other countries," he said. "If the rifle suffered from serious technical deficiencies - systematic failure - that would have come out a long time ago."

Moving the goal posts

Schulte believes that H&K has a good case because the government moved the goal posts since the rifle first came into use in 1996. And anyway, a new iteration of the G36 would certainly be an improvement: "Technological advances however already allow the production of rifles suited for a broader range of operational and climatic conditions," said Schulte.

Friday's court case is H&K's chance to clear its name, but even if the Defense Ministry does stick with its decision to ditch the G36, it's far from the end for the gun-maker, who, lobby watchdogs have pointed out, maintains excellent relationships with the ministry.

"There are several possible alternative candidates that could be considered by the Defence Ministry," said Schulte. "However, Heckler & Koch itself remains an option as the familiarity of the Bundeswehr with the company's products and an established training and supply logistics are all arguments in favor of the company." Despite being on opposite sides in Koblenz, it seems clear that the firm and the German military have developed a co-dependent relationship.