Iranian ground forces have pushed about 18 miles into Iraq across the marshy southern battlefront in a fierce new offensive that appears to have caught Iraq off guard.

Military communiques issued yesterday in Baghdad said Iraq had launched air, ground and missile counterattacks to halt the invasion, which began early Tuesday.

Early today, an Iranian ground-launched missile hit the Iraqi capital of Baghdad, the Iranian general staff announced, according to Agence France-Presse. Two hours later, Iraqi aircraft raided northern Tehran, with two rockets hitting about two miles from the residence of Iranian leader Ayatollah Ruhollah Khomeini, according to an AFP reporter who reached the scene of the attack.

Iraqi planes also raided the northern Iranian city of Tabriz early today, the official Iranian news agency IRNA said.

The Iranian ground offensive put Iranian forces within six miles of a portion of the main highway connecting Baghdad with the key southern port of Basra.

Foreign reporters and an Iraqi businessman traveling the 300-mile-long highway yesterday reported intense shelling and heavy fighting around a strategic road junction at Qurnah, which is near the confluence of the Tigris and Euphrates rivers and about 42 miles north of Basra.

The Iranian offensive, the first large-scale ground assault this year, followed a week of severe air, artillery and rocket attacks on cities by both sides, in violation of last June's United Nations-brokered accord to spare civilian targets. The two nations have been at war since September 1980.

Iran accused Iraq yesterday of using chemical weapons in the ground fighting and threatened to retaliate in kind unless the United Nations intervened.

Iranian Deputy Foreign Minister Hosein Kazem-Pour Ardebili told a news conference in Iran that Iraq had used artillery shells containing chemicals, causing an unspecified number of casualties.

"We think the lack of a stand by the international community against Iraq's use of chemical weapons indeed authorizes us to use chemical weapons against Iraq, but we still hope the international community will be able to stop Iraq," Ardebili said.

A year ago, U.N.-appointed experts investigating a similar Iranian complaint reported that Iranian soldiers fighting along the southern front appeared to have been the victims of mustard gas and a nerve agent. Iraq had no immediate comment on the latest allegations.

The Iranian offensive appeared to be aimed at isolating the southern region of Iraq from the rest of the 733-mile battlefront.

An apparent indication of Iraq's concern over the latest invasion, which followed more than a year of threats by Iran to launch a major offensive, was the announcement from Baghdad that top Iraqi generals, including Deputy Supreme Commander Adnan Khairallah, were flown to the scene of the fighting to supervise the counteroffensive.

Iranian military communiques did not indicate how far the offensive had progressed but the Iranian news agency reported yesterday in Tehran that "over 700 Iraqi troops were either killed or wounded" and that several hundred had been taken prisoner. Iraq, meanwhile, said it had inflicted "very heavy casualties" on the Iranians and destroyed more than 120 boats and four troop-carrying helicopters.

Iran has been unable to sustain for more than a few days the series of offensives it has mounted against Iraq because of logistical problems caused by international arms embargoes.

Iran announced yesterday it would resume shelling Basra in retaliation for Iraqi air force attacks against three Iranian cities: Isfahan, the country's second largest city; Bakhtaran, formerly known as Kermanshah, in the central battle zone, and Rasht, on the Caspian coast north of Tehran.

Iraq, charging that Iranian border cities were being used as staging points for further Iranian ground attacks, threatened to "raze the ground bases in these towns" without regard for civilians in the area.