Ayatollah Sayed Mohammed Hosein Beheshti, 52, who died in the bombing of his party's headquarters last night, was widely believed to be the most powerful active politician in Iran, second only to the ailing Ayatollah Ruhollah Khomeini.

Since the overthrow of the late shah, Mohammad Reza Pahlavi, in 1979, Beheshti gradually amassed political power at the expense of his rival, Abol Hassan Bani-Sadr, who was ousted as president just a week ago. Beheshti was widely belived to be the man most responsible for Bani-Sadr's downfall.

The bearded ayatollah was founder and leader of the fundamentalist Islamic Republican Party, which controls the country's parliament, or Majlis. He was also chief judge of the Supreme Court and was believed to wield strong influence in the Revolutionary Guards and komitehs, semi-independent Islamic security forces.

After the ouster of Bani-Sadr, Beheshti was named to the three-man presidential council charged with taking over Bani-Sadr's duties and holding new elections.

The death of Beheshti and many of his lieutenants in last night's explosion following so quickly after the ouster and disappearance of Bani-Sadr appeared to leave power in Iran up for grabs. The most logical candidate to move into the vacuum appeared to be Prime Minister Mohammed Ali Rajai, a protege of Beheshti, who reportedly survived the blast.

Ayatollah Beheshti was born in Isfahan, the son of a clergyman. Before the removal of the shah he served for five years as head of a mosque in Hamburg, West Germany. Because of his experience abroad, he spoke both English and German well.

The ayatollah first became visible as an aide to Khomeini when the elderly leader of the Iranian revolution was in exile in France. He continued to advise Khomeini after the Islamic revolutionary government was formed.

In the early stages of the hostage crisis, Beheshti appeared to favor release of the Americans held in the U.S. Embassy and the Foreign Ministry. But after Bani-Sadr was elected president by a large majority in January of last year, Beheshti switched sides and began obstructing efforts to arrange the hostages' release.

"Beheshti has an interest in keeping the pot boiling," one U.S. source was quoted as saying at the time, implying that the ayatollah hoped Bani-Sadr would get bogged down in an unproductive effort.

In his rise to prominence, Beheshti made many enemies, so it was impossible to know immediately who might have been behind the bombing of his party's headquarters. When leftist supporters of Bani-Sadr demonstrated in the streets of Tehran last week their loudest chant was, "Death to Beheshti."

But other groups such as Forqan, which was blamed for an assassination attempt on another ayatollah Saturday, could just as well have had reasons to bomb the party headquarters.