For Britain's hard-pressed armaments industry, it was a lucrative deal with a trusted ally. Between 1971 and 1976, the increasingly despotic Shah of Iran had signed on the dotted line for 1,500 state-of-the-art Chieftain battle tanks and 250 repair vehicles costing £650 million. Even better, Persia’s King of Kings paid the British government for his new weaponry up front.

The problem came in 1979 when, with just 185 tanks delivered to Tehran, the Iranian Revolution deposed Shah Pahlavi and installed an Islamic Republic with a somewhat less warm stance towards the United Kingdom. The massive deal, fully sanctioned by the Ministry of Defence, foundered and the Iranians, perhaps understandably, asked for their money back.

London refused and - after flogging a number of its suddenly surplus tanks to Iran’s most bitter enemy in the shape of Saddam Hussein’s Iraq - the British government has for 30 years fought a little-noticed but bitter legal wrangle in an obscure international trade court based in the Netherlands to hold onto what remains of the Shah’s money.

Until now.

The Independent can reveal that Britain is to pay back nearly £400m to Iran’s defence ministry after finally admitting defeat in the dispute in a move that will be heralded by Tehran as a major diplomatic triumph while it continues its international brinkmanship with the West over its nuclear ambitions.

Financial restrictions imposed by the European Union on Iranian banks, which freeze any of Tehran’s assets held abroad, mean that Iran will not be able to access the funds. They will instead be held in a trust account overseen by independent trustees. The money will join £976m of Iranian assets already frozen in Britain.

But the surrender of a large sum of public money to the very arm of the Iranian government accused of spearheading the development of a nuclear weapon is embarrassing for Britain and likely to be seized on by Tehran as evidence of British hypocrisy in its dealings with the Islamic regime. One British source said: “Given the context of current relations, a large payment of this type looks like a propaganda gift.”

It is understood that the settlement between International Military Services (IMS) Ltd, the state-owned private company used by the MoD to strike the tank deal with the Shah in the 1970s, and the Iranian Ministry of Defence and Support for Armed Forces Logistics (MODSAF) will be finalised in the coming weeks. The final payment, including three decades of compound interest, is expected to be about £390m.

The MoD insisted that the pay out will not come from its own stretched budget. In anticipation of a defeat as far back as 2002, Britain paid nearly £486m into the High Court to meet the cost of any settlement.

A Government spokeswoman told The Independent: “The dispute between International Military Services Ltd (IMS) and Iran relates to contracts signed in the 1970s with the pre-revolution Iranian regime. EU sanctions will prevent the current Iranian regime from accessing funds resulting from this case and could be released only if sanctions are lifted.

“Funding to meet the settlement was paid to the High Court jointly by the Treasury and IMS in 2002 - it will not come from the defence budget. IMS is a private limited company but is owned by the Government. It is rightly subject to, and will comply with, UK and international law.”

The multi-million pound agreement will bring to an end one of the more tortuous and murky sagas in that most opaque and scandal-riddled area of international affairs - nation-to-nation arms deals.

Bloated by surplus cash from Iran’s oil wealth, the notoriously autocratic and ruthless Shah became a favoured client of British and American arms companies during the 1970s as he developed a vast arsenal of state-of-the-art weaponry from his key allies, including US F-14 and F-15 fighter planes which remained in service in the Iranian air force until recently.

Two of the biggest deals of the era were struck between IMS and the state-owned Royal Ordnance Factories (ROF), and the imperial Persian military for Britain’s much-admired Chieftain battle tank, at the time the most powerful and technologically-advanced weapon of its kind, and a modified version known as an Armoured Recovery Vehicle (ARV), used to retrieve damaged tanks from the battle field. A total of 1,500 Chieftains were ordered in 1971 and a further 250 ARVs bought in 1976 at a total cost of £650m, paid in advance by the Iranian government.

The enormous project, reminiscent of the subsequent vast Al Yamamah deal struck between Britain and Saudi Arabia under Margaret Thatcher, involved more than the supply of large quantities of the United Kingdom’s most prized military hardware. As well as offering training to the Shah’s army, Britain agreed to build an industrial complex near the city Isfahan to manufacture Chieftain parts and ammunition.

The deal was hailed as a major coup for Britain, guaranteeing thousands of jobs at ROF plants in the industrial heartlands. Such was the importance of the scheme that in the immediate aftermath of the Iranian revolution which swept Ayatollah Khomeini to power, Britain continued to supply tank parts to Tehran.

But the outbreak of the Iranian hostage crisis, during which 53 American embassy staff were held for more than a year, put paid to any lingering hopes of resuming the deal - sparking panic in the British government about the future of the armaments industry and what to do with the dozens of Chieftains and ARVs parked in factories awaiting delivery to Iran.

Recalling the trepidation in MoD circles, David Gibbons, the senior commercial officer of IMS told Sir Richard Scott’s 1996 Arms to Iraq Inquiry: “When the Revolution occurred something akin to panic broke out within the MoD/ROF axis. Export approvals across the board for military contracts were withdrawn. The MoD was faced with the nightmarish prospect of wholesale redundancies and disorganisation within [the arms industry]. As a result there was imminent danger of the partial collapse of a significant sector of the UK defence industry, with the attendant political and industrial consequences.”

In order to avoid such disarray, the Thatcher government hastily agreed to sell 279 Chieftains to Jordan. What it did not declare publicly was that, under the cover of the Jordanian deal, Britain was also selling 29 surplus ARVs to Saddam Hussein’s Iraq shortly before it began its bloody eight-year war with Iran, which claimed 500,000 lives.

Such was the secrecy of the 1980 deal, which would have contravened Britain’s stated position of neutrality in the Iran-Iraq war, that all IMS records relating to it were shredded apart from a letter signed by Lord Strathcona, a junior MoD minister, authorising the transaction. That document was kept locked in a safe at IMS’s central London offices.

When Iraq later tried to buy spares for the ARVs in 1985, senior British military officers unaware of the clandestine sale assumed they were for use to repair Iranian Chieftains captured in battle. The Independent understands that it is likely Saddam used the ARVs immediately after their arrival from Britain as a source for spare parts for Iranian tanks captured early in the war, thus enhancing his battlefield capacities.

The revelation of such cloak and dagger activity by the Arms to Iraq Report provoked an angry response from Iran, which complained bitterly to London that such evidence of double-dealing had added insult to the injury of Britain’s continued refusal to repatriate the tank deal money paid by the Shah.

Jim Cousins, the retiring Labour MP for Newcastle Central, who has raised the ongoing dispute in Parliament, said the matter was raised angrily during a visit by British MPs to Tehran in 1997. He said: “The Iranians consider this to be a very important issue. There is a very strong perception that they were cheated on the tank deal. They feel very strongly that Britain keeps lecturing them on the importance of the rule of law and adhering to contracts, and that it has been hypocritical by clinging onto the funds from a deal made more than three decades ago.”

Armed with massed ranks of international lawyers, both sides took their fight to the arbitration court of the International Chamber of Commerce sitting in The Hague, where the dispute remained mired in litigation until Britain lost its final appeal against a finding that it was liable to pay the outstanding sum in April 2009. The final settlement, expected before the end of May, will be registered with the High Court in London.

The Iranian Embassy in London yesterday declined comment on the negotiations. Professor Ali Ansari, the leading Iran expert, based at St Andrews University, said: “I think there will be surprise that this could not have been done more quickly. It has taken an enormously long time to get resolved. Any debtor will always drag their feet but London has dragged this out spectacularly. I suppose this shows the tenacity of Iran on these matters. They really do not let these things go.”

The government-owned company at the heart of the deal

With its offices situated a conveniently short walk from the Ministry of Defence, International Military Services Ltd was the private company with a difference that placed itself at the heart of a string of lucrative and controversial arms deals throughout the 1970s and 1980s.

While it outwardly behaved like any other limited company, the reality was that the behind its brass plate on Abbey Orchard Street in Westminster, IMS Ltd remained owned entirely by the British government.

The company, whose sole shareholder was the Secretary of State for Defence, was set up in 1974 under Harold Wilson's Labour administration, ironically with the aim of cleaning up state-sponsored arms deals in Britain by removing the need for agents and middlemen who took excessive "commissions" in previous deals with other states.

Staffed by senior civil servants and trusted City executives, IMS and its predecessor, Millbank Technical Services (MTS), was designed to put the MoD at arm's length from the process of securing and discharging defence export contracts "in the interests of the Government and of industry".

This quasi-official status allowed IMS to act as a "trustworthy intermediary", according to internal MoD documents. Under these arrangements the company would "buy" armaments in a paper transaction from the Government and/or manufacturers. Once the goods had been sent to the foreign customer, critics of MTS said it had been able to present an inflated bill that included bribes paid to secure the deal. There is no evidence that the practice was continued by IMS before it ceased trading in 1991. Over a period of about 15 years, IMS set up offices in India, Saudi Arabia and Iran, where it oversaw the deal to sell Chieftain tanks and Rapier missiles to the Shah. Until 1985, it was headed by Lord Cuckney, a former MI5 officer who became one of Margaret Thatcher's favourite businessmen.

During the 1980s, IMS branched out into providing support services for the military forces of foreign regimes. In 1985, the Conservative trade minister Lord Sainsbury said: "This can and does cover a wide range of activities but it can be defined in general terms...as the supply of military equipment and the provision of associated support such as the installation, commissioning and maintenance of equipment and the training of personnel."