Terrorists shot and killed a leading American oilman and an Iranian employed by the same firm in separate street ambushes today in the southwestern oil-producing center of Ahwaz, 340 miles southwest of Tehran.

Paul E. Grimm, 56, a Texas executive serving as the acting managing director of the Oil Service Co. of Iran (OSCO), died in gunfire when three men armed with automatic weapons waylaid his car in a well-organized attack, U.S. officials said.

He was the first foreigner killed in the past year of unrest against the shah, although many other Westerners - including Grimm himself - have been threatened with death unless they leave the country.

The last time Americans were killed in terrorist violence in Iran was in 1976, when a colonel and a major were ambushed while driving in Tehran.

About the same time Grimm was killed, Malek Boroujerdi, a production superintendent for OSCO in the Ahwaz oilfields, was gunned down while driving to work.

There also were unconfirmed reports that another Iranian production superintendent was shot at the Gachsaran oilfield.

The shootings came amid mounting antiforeign harassment as martial law authorities enforced tough measures to break an oil worker's strike now in its third week.

A number of leaders of the strike that was called by exiled religious leader Ayatollah Ruhollah Khomeini have been arrested and face trial before a military court.

Grimm and other foreign employes of OSCO-operational arm of the Western consortium that produces more than 90 percent of Iran's oil under a service contract with the National Iranian Oil Company-have received threatening notes in recent weeks warning them to leave Iran.

But the killing of Grimm and Boroujerdi appeared to be the work of an urban guerrilla group not directly involved in the oil workers' strike, security sources said.

"This is an act of terrorists, not disgruntled workers," one official said. "The people who have been dropping leaflets are not the same ones who squeezed the triggers of those automatic weapons.

No group immediately claimed responsibility for the attacks but the sources said the method of attack pointed to one of two urban guerrilla organizations which have been stepping up activities during the current unrest. The two groups are the People's Strugglers and the People's Sacrifice Guerrillas, which is avowedly Marxist and his links with radical Palestinian guerrillas.

Security sources said they suspected the first group, which has been blamed for the murders of six American in Iran the past five years.

Grimm's widow, Byrdine, said by telephone from her home in Ahwaz shortly after her husbane was killed, that, "I did not have any idea anything like this would happen."

Struggling to keep her voice enen, she said there had been "no indication whatsoever" of such an attack despite the threatening notes received by her husband and other Western oil officials in the region.

One of Grimm's three children, Russell, said from his home in Marlborough, Conn., that "the onlk information I've gotten so far was...that my father was ambushed in Ahwaz on the way to work and was shot."

[In New York, Texaco board chairman Maurice Granville said the company was "shocked and saddened" by the killing of Grimm, who started with the firm in 1948 as a roustabout on an oil rig in Colorado and was appointed to his post in Iran in July 1976].

A visitor to Ahwaz who saw Grimm a week ago said that a handwritten note had been left on his desk while he was out to lunch a few days earlier. "Remember, before New Year you must leave this country," it said.

According to the visitor, Grimm dismissed the note, saying: "I'm not scared by that sort of thing."

Yesterday, a few hours before his death, an explosion ruptured a crude oil pipeline in a field near Ahwaz, causing a loss of some 500,000 barrels worth $6 million. Oil industry sources blamed saboteurs although there was no immediate indication who was responsible.

Las t month, the American management director of OSCO, George Link, was the target of a fire bomb attack as he rode in his chauffeur-driven car in Ahwaz. The car caught fire but Link escaped unhurt. Link is now on vacation and Grimm, his deputy with the title of general manager for operations, had been filling in.

In Tehran, the car of a U.S. military mission official was set on fire tonight, sources said. Last night a powerful explosion wrecked the offices of the Western Electric Co. and 24 hours earlier a gasoline bomb was thrown through a window of an American home.

There were no casualities in any of these incidents, or during an anti-shah and anti-American protest in Tehran today by about 1,000 high school students.

Diplomats said the terrorist attacks were bound to increase the foreign exodus from Iran that began before Ashura.

Grimm had come in for criticism from martial law authorities in Ahwaz as well as from the strikers. The local military administration had accused the western managers of OSCO, including Grimm, of not cooperating fully with strict measures aimed at forcing strikers to return to their jobs.

According to informed sources, Grimm had resisted requests from the authorities to draw up lists of workers who were either on strike or engaged in an industrial go-slow. He complained that the military was trying to enforce martial law through his office.

"He was trying to maximize oil production, but without becoming involved in Iranian politics," one souce said. Another described him as being caught in a "hellish" position between the two sides.