Army tanks and troops clamped a dusk-to-dawn curfew on the ancient capital of Isfahan yesterday to end 18 hours of anti-Shah rioting and arson in the Moslem extremist stronghold.

Four rioters were killed in the disturbances, which erupted Thursday night, just hours after the Shah called reporters to his summer palace to assert he was "not just another dictator" but would crush extremists who tried to block his moves toward political liberation.

Maj. Gen. Reza Naji, military commander of the region, early yesterday moved tanks and armored cars into Isfahan, 257 miles south of Tehran, declaring martial law for a month after riot police failed to stop hundreds of religious demonstrators from rampaging through the ancient city, wrecking and burning banks and stores.

Isfahan is a city of nearly a million people, with several big industries and foreign companies.

Gatherings of more than three persons, including religious gatherings in mosque during the current Moslem holy month of Ramadan, were banned.

The U.S. consulate asked the 12,000 Americans in Isfahan to stay indoors until further notice. The Americans mostly are involved in civil construction projects and a few defense-related industries being built by Iran's government.

Authorities in Tehran said that four rioters were killed and seven wounded when police opened fire to quell the antigovernment demonstrations Thursday. Seven policemen suffered bullet wounds and 38 others were injured by flying rocks and bricks, they said.

The rioters attacked and set fire to a big luxury hotel, smashed the windows of banks and movie theaters, damaged cars, and attacked fire engines, injuring 40 firemen, they said.

The scale of the rioting appeared to be the biggest yet in a wave of protests against the shah's government throughout the country this year.

"The most dangerous animal is the politically irresponsible leader who has no sense of patriotism," the shah told reporters at the summer palace near Nowshahr, a Caspian Sea resort 126 miles north of Tehran.

"I'm not just another dictator. I am a hereditary monarch. I've got to do these things," he said of his liberalization program.

The shah said he would guarantee 100 percent free elections, freedom of the press and the right to peaceful demonstrations.

He said his opponents would "try to hide their weakness by creating trouble. But nobody can stand that. No respectable government can stand that. If they want to play the game, it must be a fair game."

A major steel and industrial center, Isfahan is well known for its beautiful Persian rugs, its blue domes, covered Persian bazaars and lush boulevards.

The clashes followed shooting at the residence of a prominent local clergyman Ayatollah Hossein Khademi, Thursday night after antiShah speeches during a religious gathering.

Khademi, a supporter of Ayatollah Khomeini, an antiShah clergyman exiled in Iraq, had been holding the religious meetings for more than a week.

Khomeini and his followers want the shah toppled and replaced by an Islamic government of high priests and theologians, while more moderate Moslem leaders say implementation of a new constitution is the best way for a political settlement.

Local residents contacted by telephone said that the disturbances in Isfahan, 200 miles south of Tehran, followed 10 days of smaller demonstrations in different parts of the city after the arrest of a local Moslem religious leader.

The violence started after a meeting in a mosque, they said, adding that thousands of people shouting slogans against the shah went out into the streets.

One of their targets was the Shah Abbas Hotel, a modern luxury hotel where many foreign tourists stay. A hotel official said last night that there was no trouble at the hotel yesterday, and refused any further comment.

Usually reliable sources said three people were killed Thursday during a big antigovernment demonstration in another major Iranian city, Shiraz, in the south, but there was no immediate official confirmation of the incident. Thirty Policemen and 180 rioters were injured in the Shiraz violence and 20 rioters were arrested, the sources said.

Iran is frequently plagued by riots by religious extremists who say reforms ordered by the shah are contrary to the teachings of the Moslem holy book, the Koran.

Many of the reforms deal with women's rights and the redistribution of church lands.