DUBAI, UNITED ARAB EMIRATES, OCT. 13 -- In one of the most devastating missile attacks of the Persian Gulf war, an Iranian warhead smashed into a Baghdad schoolyard today, killing 29 children and three adults and wounding more than 200 people in neighboring buildings demolished by the blast, according to Iraqi officials and western diplomats.

Iraq's military command issued a warning after the attack, saying Iran "wanted a war of the cities, so let it be. Iraq's patience has run out and it has become our right, but also our duty, to reply to this ugly crime."

Iran's Revolutionary Guards Corps said in Tehran that the surface-to-surface missile was fired at Iraq's Defense Ministry compound in retaliation for Iraqi bombing attacks on civilian targets in Iran, including an attack yesterday on an Iranian school in Sohail, in Lorestan Province.

The missile, believed by analysts to be a long-range Scud-B of the type Iran purchased from Libya, fell 12 miles from the Defense Ministry. Iraqi officials did not allow publication of the precise location of the school under a policy designed to prevent Iran from learning the accuracy of its missile strikes.

Iraqi officials said that at least 98 people were seriously wounded by the missile, which destroyed 30 houses and blew out windows in hundreds of buildings within a one-mile radius of the impact zone in central Baghdad.

Iraqi officials allowed 50 foreign diplomats and journalists to view the destruction. It was the fourth Iranian missile attack in eight days and appeared certain to draw retaliatory bombing raids by Iraq's Air Force on Iranian economic and civilian targets.

King Hussein of Jordan and President Hosni Mubarak of Egypt sent messages of sympathy to Iraqi President Saddam Hussein, Iraq's INA news agency said, according to Reuter.

The missile struck at 7:55 a.m., just as 650 elementary pupils were preparing to enter classes at the Palace of the Martyrs School.

Reuter correspondent Subhy Haddad said from Baghdad that the school grounds looked like an earthquake zone. Other witnesses said the school building collapsed from the force of the impact, sending a huge cloud of dust and smoke into the air over the city of 4 million that straddles the Tigris River.

"The children were singing songs in the playground when the missile landed," said Iraq's foreign press director, Salah Mukhtar.

Haddad said textbooks and schoolbags were scattered through the rubble of the school building, which surrounded a 30-foot crater at the impact site. Wrecked automobiles and bloodied textbooks littered the streets around the school, Haddad said.

He said parents who rushed to the scene wailed hysterically as bulldozers pushed away the structural wreckage and uncovered the bodies of youngsters between the ages of 7 and 12.

The grief-stricken father of two small girls pulled from the debris beat his face in anguish. A middle-aged man sitting in shock amid the broken masonry said both of his children had been killed. Another woman pulled at her hair and told Haddad she had lost two children.

The school's principal, Ismail Geitan Jassim, who was 300 feet from the impact site, wept as emergency teams searched for bodies. "I collapsed," he said, describing the moment of impact, "and when I got up it looked like a battleground, an earthquake. Everything was rubble."

The missile attack comes at a time of international focus on the Iran-Iraq war and a major deployment of naval forces by the United States and six western maritime powers to the Persian Gulf waterway. The war there has resulted in widespread assaults on international shipping.

The timing of the attack appeared certain to inflame further the conflict as both sides prepared for the annual rainy season offensives in the land war along their 700-mile frontier.

In the gulf today, an Iranian warship attacked a Saudi Arabian tanker, the Petroship B, within the territorial waters of Dubai, according to shipping sources. The 39,115-ton tanker was on its way out of the gulf when the Iranian frigate opened fire, the sources said. The tanker was only slightly damaged.

The attack was Iran's first on merchant shipping since the Oct. 8 assault by U.S. helicopter gunships on three Iranian gunboats that reportedly fired shots in the direction of the helicopters as they were monitoring gunboat movements near Iran's Farsi Island base off the Saudi coast.

Meanwhile, a large convoy of Kuwaiti tankers flying the American flag completed its gulf transit from the Strait of Hormuz to Kuwait's oil-loading terminals in the northern gulf.