Iran today accused Iraq of launching an attack three miles into a main oil-producing region near this country's southern border, but officials later said the invaders were "retreating" and that the crisis had been "resolved."

The official Tehran Radio implied that the United States had instigated the attack because it had been "defeated" in its efforts to pressure Iran into freeing 50 American hostages being held at the U.S. Embassy in Tehran.

Ayatollah Ruhollah Khomeini today denounced the U.S. effort to enlist its Western allies in economic sanctions against Iran as an attempt "to make us starve." He said that President Carter "wants to free the hostages just because he wants to be president a second time."

The sketchy reports of an Iraqi incursion pointed to new tension over a coveted area that historically has been disputed by Iran and its Arab neighbor to the west.

The official Iraqi News Agency said it had no information on the reported border clash, and Iranian government officials claimed to know nothing about it either.

A brief announcement by Iranian radio and television tonight said, "Iraqi forces armed with heavy weapons launched an aggression on a section of the Iranian border." It did not say when the attack occurred, nor precisely where.

Reports from southwestern Iran said Iraqi forces attacked the border post of Shalamchech, 12 miles northwest of the port of Khorramshahr in Iran's oil-rich Khuzestan Province.

Revolutionary Guards in the provincial captial of Ahwaz said a firefight two days ago at the border town of Dashed Azadajan cost the lives of four Iraqi border police.

[In Washington, Defense Secretary Harold Brown said he had "no information that would suggest that there has been an invasion" of Iran by Iraq and could not confirm Iranian media reports of an attack.]

In commenting on the alleged attack, Tehran Radio said, "The aggression by the Iraqi mercenaries is taking place at a time when Carter's government and its agents have been defeated in their confrontation against the will and determination of the Iranian nation."

About three hours after the first report of the attack, a Foreign Ministry official said, "They are retreating across the border. The problem has been resolved."

Nevertheless, the incident seemed likely to exacerbate the continuing deterioration in Iranian-Iraqi relations, which has shattered an unusual era of good feelings inaugurated in 1975.

Foreseeable as soon as Iraq in effect expelled Ayatollah Ruhollah Khomeini -- then living in exile in Najaf south of Baghdad -- in October 1978, the deterioration has reached the point where the neighbors recently closed down their respective consulates and now make little pretense about their efforts to undermine each other.

In March 1975, Shah Mohammad Reza Pahlavi, at the height of his power, withdrew support from an Iraqi Kurdish rebellion that was endangering the Baghdad government. In return he achieved his longstanding goal of winning half of the vital Shatt-al-Arab estuary.

In late October, the official newspaper of Iraq's ruling Baath Party, Al Thawra, in effect denounced the treaty and told Iran it should prove its proclaimed good intentions toward the Arab world by returning three previously Arab-held strategic islands in the Strait of Hormuz occupied by the shah in 1971.

The tables have turned. A strong Iraq under President Saddam Hussein is now attempting to dictate terms to its neighbor beset by revolutionary chaos.

Now Iranian officials routinely accuse Iraq of financing and arming their Kurds, attacking a television transmitter here and an airfield there. They also accuse Iraq of complicity in blowing up pipelines and other installations in Khuzestan, where Iraq is again showing its sympathy and support for local liberation fronts representing the province's large Arab population.

In turn, Iraqi officials accuse Ayatollah Ruhollah Khomeini and his Shiite Moslem clergy of deliberately exporting Islamic revolution to Iran's Arab neighbors, especially those with large Shiite populations.

Invoking the example of his own use of ordinary people against constituted authority, Khomeini himself last week warned Arab leaders that theirs could be a fate like the shah's if they did not back Iran in its hour of need. The specific case he mentioned was using the oil weapon against the United States, but his implied threat on a wider scale was not lost on Iraq's nervous rulers.

The secular government in Baghdad, run by Sunni Arab Moslems who are in a minority in Iraq, are nervous about Khomeini's ability to stir up the country's Shiites, who are said to number half the total population.

During the late November holiday of Ashura, commemorating the death of the Shiite martyr Imam Hossein, at least two Shiites -- and perhaps as many as 12, according to Iranian newspapers -- were killed in disturbances in Kerbala, a venerated Shiite shrine 50 miles south of Baghdad.

Iraqi officials said the violence was instigated by an unnamed "foreign power," which in the context could only have meant Iran.

With relations at such a low ebb, some analysts believe Iraq might be tempted to take advantage of Iran's military and political weakness to occupy Khuzestan and take over its oil riches.

There was no further word from the government today about the formation of an international team of observers to visit the hostages, as ordered by Khomeini yesterday.

In denouncing U.S. efforts to get other nations to join economic sanctions against Iran, meanwhile, Iranian authorities said today that such moves would not speed the release of the hostages.

"President Carter thinks of himself as a humanitarian," said Ayatollah Khomeini. "But he sent Secretary of State [Cyrus R.] Vance to European countries to mobilize them for an economic blockade against us."

Appearing on national television, Khomeini said that Carter "wants to mobilize the whole world against us to make us starve. He thinks he can, but nobody paid attention to that."

Khomeini called the Vance trip "a political defeat" for Carter.

The Iranian Foreign Ministry announced tonight that it is calling back ambassadors from France, West Germany and the Scandinavian nations for consultations, but it did not say whether this was related to Vance's tour.

The director of foreign press for the Ministry of National Guidance, Abol Ghassem Sadegh, told reporters that Vance's attempts to mount an economic blockade of Iran was a sanction "out of proportion" to the holding of the hostages in the embassy.

"It will not change our minds" about freeing the hostages, said Sadegh.

He said any economic blockade against Iran will polarize the Moslem world against the West, and "as far as I am concerned that is of much greater importance than what might be happening in the American Embassy."

He said the 50 hostages in the embassy are "safe and sound," and will probably go on trial shortly.

Militant students occupying the embassy, meanwhile, released a tape recording of a telephone conversation between one of the hostages and his wife in the United States.

In the 15-minute conversation, Jerry Plotkin, 47, a private businessman from Sherman Oaks, Calif., said, "The only way we'll be free is for them [American officials] to return the shah."

It was obvious that some of the students were present when Plotkin was talking to his wife, Debby. At one point he mentioned to someone else in the embassy that she was crying.

He told his wife he believed the students "are absolutely right" and that American opinion must change to accept their point of view.

Plotkin came to Tehran Oct. 31 to set up a business to find personnel for American companies in Iran. He said he just happened to be in the embassy when the students took it over on Nov. 4.

He told his wife he is physically fit although he has lost 25 pounds and started smoking again.

The students announced that they would allow the hostages to get some, but probably not all, of the Christmas cards that were sent to them.