Iraq is showing increased flexibility in efforts to end the stalemated 18-month-old battle with Iran for supremacy at the head of the Persian Gulf.

The softened Iraqi terms for peace negotiations are a measure of the eagerness in President Saddam Hussein's government and Iraq's populace to halt the fighting and its drain on human and financial resources 1 1/2 years after the outbreak of a conflict that was expected to last only a few weeks.

They also reflect unease at the prospect of a continuing war--within an enemy warplane's easy striking distance from here--during a summit conference of nonaligned nations scheduled for September in Baghdad. Hussein is to assume the movement's presidency then--a coveted boost for his international prestige that could be marred by an Iranian attack.

After Iraq made rapid advances along the front and captured hundreds of square miles of Iranian territory early in the fighting that began in September 1981, the war bogged down for nearly a year until last December, when Iranian attacks pushed back Iraqi forces in several areas.

An Iraqi counteroffensive last month drove Iran out of some of the territory it had just recovered, but the inconclusiveness of the new Iraqi effort has left the war at a standoff, in the view of outside observers here.

Taha Yassin Ramadan, first deputy prime minister and member of the Revolutionary Command Council, said in an interview that Iraq is prepared to withdraw from captured Iranian territory in stages before conclusion of a peace agreement provided talks have begun "directly or through other parties" and show satisfactory signs of progress.

Western diplomats following the conflict said this marked a concession from previous Iraqi formulations that demanded agreement with Iran's Islamic leadership before beginning withdrawal from the 6,000 square miles occupied since September 1980. The more flexible Iraqi stand has been conveyed to Iran through an Islamic Conference mediation team that visited both countries last week, they said.

But Ramadan, who commands Iraq's growing Popular Army and is considered the third-ranking member of Hussein's Baath Party regime, added that Iran has not responded to the Islamic team with anything to indicate it is willing to negotiate peace on the Iraqi terms.

"Nothing has been communicated to us," he said in the interview.

Ramadan was careful to specify that Iraq still rejects the idea of withdrawal before negotiations begin, a major Iranian condition for peace talks so far.

"The linkage of negotiations and withdrawal is natural, in such a way that would guarantee the rights of both sides," he said. Asked whether withdrawal could nevertheless begin before the negotiations are completed, he replied: "This is subject to the negotiations. It could be done in stages."

In another shift seen by Western diplomats as a sign of flexibility, Ramadan refused to specify what "rights" Iraq would consider the minimum acceptable should negotiations be arranged. Previously, Iraq has insisted on sovereignty over the Shatt al-Arab waterway leading into the gulf, return of two disputed border areas and a noninterference pledge by Iran's Shiite leaders.

Although the latter two goals remain firm, there are increasing signs Iraq would agree to a sharing agreement with Iran in the Shatt estuary if such an accord offered a way out of the war, the diplomats said.

"It is impossible for either country to use the Shatt al-Arab ports except on the basis of good neighborliness," said an Asian diplomat.

Iran and Iraq shared sovereignty over the waterway under an accord worked out in Algiers in 1975 between Hussein and the shah. Iraq abrogated the agreement before the war, charging it was forced on Hussein under duress and violated the spirit of other accords dating from Ottoman times giving Iraq sovereignty over the Shatt.

The Iraqi leadership considers control over the waterway especially important because it is the nation's only outlet to the sea. This is a vital requirement for oil exports that fuel a high-speed development program now threatened by the war.

Despite the increased flexibility in public peace terms, Hussein's leadership is still girding to meet the demands of war for another year and perhaps more. The new perspective for long-term planning was reached after a hard reappraisal over the last several months, diplomats here say.

"We are seizing any opportunity for peace in such a way as will guarantee our rights, but at the same time we continue working as if the war will continue for years," Ramadan said. "There is hope in human terms that we can end this war. But we draw up our plans on the basis that the war will continue for another year. We are not worried about continuation of the war."

In an interview broadcast by a French television network last week, Hussein made a similarly glum assessment of chances for an early peace.

"It seems to us that the war will not continue for more than another year and a half or two years," he said. "If the war continues for more than two years, we will draw up our plans in a manner enabling us to continue with the same determination for the additional years. Surely the situation in Iran will not stand two more years or one and a half more years of war."

The comments reflect a judgment said by diplomats to be widely held in the Iraqi government that as long as Ayatollah Ruhollah Khomeini remains the paramount Iranian leader, negotiated peace will be very difficult even with Iraqi concessions.

They also grow from a hard reading of the military situation along the 300-mile front, the diplomats say.

Iraqi forces last month recovered some of the Iranian territory they had earlier held around Bostan, 120 miles north of the Shatt al-Arab. The territory had been lost in a serious Iraqi reversal in December. Official Iraqi reports say Iraq's forces have retaken control over the sandy heights at Bsateen west of the town, commanding access toward the Iranian-Iraqi border, but have not sought to recapture Bostan itself.

The battle to retake Bsateen met success only at the cost of heavy losses, diplomatic sources say. Although Iraq has not announced its casualties in the February fighting, it has claimed it killed 7,700 Iranian troops and wounded "great numbers."

The counteroffensive nevertheless has been hailed as a great victory here. Hussein visited the area to mark the success. On his return to Baghdad he had to go on television to ask the capial's residents to stop the wild submachine-gun firing that celebrated the triumph--and exposed the city to bullets raining back to earth.

As a result, morale has markedly improved in Baghdad and at the front in the last few weeks, diplomatic observers report. Although the Army has refused to take foreign journalists to the area, it is said to feel confident that its regained positions can prevent an Iranian push through the Bsateen passage into Iraq.

Losses during Iran's December move through Bostan were accompanied by a number of troubling Iraqi desertions, the observers say. But Iraqi troops are said to have fought well in recapturing Bsateen last month and since then have harassed Iranian lines with repeated small offensives.

At the same time, Iraqi forces have not returned to the other side of the Karoun River, where they were forced back by an Iranian counteroffensive last fall near the Iranian oil port of Abadan. This, taken with the inconclusive Bsateen exchange, leaves an impression of standoff.

"The push at Bostan raised the question whether they the Iranians had the capability to advance," said an Asian diplomat. "The Iraqi counteroffensive, I think, showed they do not. But the Iraqis don't seem to have the capacity to push them back, either. So really the war is in a stalemate."

Western diplomats here speculate that Iran may try a heavy spring offensive in the coming weeks, taking advantage of the drier weather to gain an advantage and embarrass Hussein before the nonaligned summit.

Iraqi forces enjoy increasingly regular air support, official reports from the military command show. According to diplomats here, recent delivery of French-made Mirage fighters has combined with the poor condition of Iran's Air Force to give Iraq a clear edge in the air over the battlefront.

Since the early days of the war, when damage was heavy, both sides have generally avoided attacking oil installations. In what could lead to more devastation, however, three Iranian warplanes attacked Iraqi oil installations at Kirkuk in the north three weeks ago.

Iraqi officials said two attacking planes were shot down and the third retreated. European diplomats said the two Iranian jets were hit by French-supplied ground-to-air missiles.