A West German company has sold a midget submarine to Iran only months after the Pentagon prevented the vessel's sale to North Korea.

The company, Bruker Meerestechnik of Karlsruhe, decided to go ahead with the deal following lengthy negotiations between its representatives and officials from the Iranian oil ministry in Hamburg last week, according to an Iranian source in London.Pentagon officials fear that the submarine could be used for military purposes by the Iranians in the gulf. They have explained how they foiled the sale of the 43-foot orange-painted exploration submarine to the Koreans under a clause in the export control list that forbids the transfer of specific Western technology to most Communist countries.

The sale of the $5 million Seahorse II had been stopped because it breached a 10-hour submersion limit imposed by the Coordinating Committee for Multi-Lateral Export Controls. COCOM, founded in 1949, includes United States, Japan and the NATO countries. It is designed to prevent the sale of strategically important technology to the Soviet bloc and other Communist nations.

The Pentagon says the U.S. government had to make a personal appeal to Chancellor Helmut Kohl to prevent the Seahorse II's original sale to North Korea. The West German government paid back more than $1.7 million in compensation to the submarine's manufacturer for issuing an earlier licence to sell the boat to North Korea.

American suspicions, however, appear to have been increased by a satellite photograph that allegedly shows a small submarine-shaped vessel in the Gulf and by a video film of Iranian naval maneuvers on Iranian television, which showed a small submersible with crewmen visible on the deck.

The Iranian government under the late shah had plans to purchase submarines from the United States and a number of naval technicians went to America to be trained. The sale was not made because of the Islamic Revolution in 1979 and the overthrow of the shah's regime.

Since then, the Iranians have used the American technicians as experts in submarine warfare, Iranian sources in London said last week.

The Iranians are said to have given assurances to the German company that the submarine would not be used for military purposes, and it was after these assurances that Brucker agreed to the sale.

Iran says it needs the submarine to clear offshore oil installations and undersea pipelines damaged in the Gulf War.