Iraq has bolstered its defenses against Iranian invaders by purchasing advanced warplanes from abroad and has established clear air superiority in the Persian Gulf war, according to Western diplomats here.

Fresh Mig 23 fighter planes from the Soviet Union and Gazelle helicopter gunships from France have helped the Iraqis drive back or contain enemy thrusts across the border. Iraqi air strength may help explain why Iran has refrained from launching a major offensive since last July, when it first invaded in the south.

The Iranians have seized small pockets of territory in two recent attacks to the north, but diplomats said that the assaults involved small numbers of men and appeared designed primarily to maintain psychological pressure against Iraq.

The deflection so far of Iran's invasion has relieved the pro-Western rulers of the monarchies in the Persian Gulf, who fear that they may be the next to fall if Iraq is defeated. Iran repeatedly has rebuffed Iraq's appeals for a truce, however, and insists that it will continue to fight until its demands are met, including the toppling of the current Iraqi regime.

Iraqi President Saddam Hussein, who ordered his troops into Iran at the start of the war 25 months ago, now acknowledges freely that Iraq is on the defensive. He even suggested this week that Iraq could gain support abroad from the presence of Iranian troops on Iraqi soil because Iran thus is shown to be the aggressor in the eyes of world public opinion.

"The recent five kilometers of territory seized by the Iranians cannot be considered a grave state," Saddam Hussein said in a speech to his cabinet. "The situation will turn into a burden on them, after which we will have the initiative. . . . When the Iranians cross the border, their evil and expansionist intentions get clearer."

Iran turned the tide in the war last spring, when it recaptured the city of Khorramshahr. Iraq withdrew its troops from almost all of their positions inside Iran in June and asked for a cease-fire.

The Iraqi Air Force had an edge over the Iranians in the spring as well, but the margin has widened with the arrival since April of the fighters and helicopters, the diplomats said. They did not say how many new aircraft had been delivered, but military specialists say that as of Sept. 1 the Iraqis still had on order 150 Soviet Mig aircraft of differing varieties and 36 French Gazelle and Puma helicopter gunships.

Iraq is estimated to have 200 or more operable combat aircraft, compared to roughly 50 Iranian warplanes. The Iranians have suffered from serious shortages of spare parts and other maintenance problems as well as from the departure of many trained pilots following the overthrow of the shah.

Most of Iran's planes are U.S.-made F4 and F5 jets, while nearly all of its F14s currently are unusable, military sources say.

Iraqi military communiques have been stressing the role played by the nation's jets and helicopter gunships in attacks against Iranian tanks, artillery and troop emplacements. The Gazelle gunship is equipped with the French-made HOT missile, a wire-guided missile similar to the U.S. TOW missile used against armor or heavy guns.

Iraq, which has paid cash for its new arms, has the funds because of financial backing from Saudi Arabia and other conservative Arab Persian Gulf states. But the improved air force has not been the only reason for Iraq's success so far in preventing a major Iranian breakthrough. Iraqi troops have fought more skillfully when defending their own country, according to observers here, and Iranian advances have been slowed by marshy or mountainous terrain.

In its most recent thrust, Iran seized up to six miles of Iraqi territory last weekend on a front about 170 miles southeast of the capital. The Iranians apparently were driving toward a north-south road, about 25 miles from the border, that leads to Baghdad.

In the other recent attack, the Iranians at the end of September assaulted Iraqi positions around the town of Mandali, 75 miles northeast of the capital. There, they were trying to push the Iraqis out of territory that Iran was holding before the war but that Iraq claims.

Neither of these Iranian assaults compared in size with the offensive in July aimed at Iraq's southern port of Basra, diplomats said. There, each side was estimated to have as many as 100,000 troops in combat, while in the autumn neither side was believed to have more than 20,000 soldiers involved, one diplomat said.

The recent fighting consisted primarily of artillery duels and Iraqi air strikes against Iranian positions. Despite the relatively small scale of activity, both sides have claimed to have inflicted thousands of casualties. It was impossible to confirm the claims.

The Iraqis have dug several lines of earth works northeast of Baghdad on the road to Mandali and previously have fought well from fixed positions. The diplomat said morale was reported to be low among Iraqi conscripts in the infantry, however.

In an apparent response to Iran's latest calls for the ouster of Saddam Hussein, a massive rally was held in Baghdad and other cities today to show support for the regime.