Massive crowds took to the streets of Tehran today to mourn Ayatollah Mahmound Taleghani, one of Iran's most influential religious leaders and a unifying force in the battle to overthrow Shah Mohammed Reza Pahlavi earlier this year.

Accompanying the mass outpouring of grief over his death of a heart attack last night was a sense of foreboding at the loss of a religious and political moderate whose broad appeal helped hold together an unlikely coalition spanning the Iranian political spectrum under Ayatollah Ruhollah Khomeini.

Scenes of wild grief bordering on hysteria broke out as crowds assembled around the mosque of Tehran University, where the ayatollah's body was taken before the start of a funeral march to south Tehran's Behesht Zahra Cemetery.

The emotional response to his death was a mark of the respect and affection won by the 68-year-old ayatollah during a long public career in which he combined spiritual duties with an active political role in opposing the shah.

His efforts cost him more than 10 years in prison and torture at the hands of the deposed monarch's secret police, SAVAK.

Taleghani emgered from his most recent sentence only last fall and was instrumental in organizing the street demonstrations and political opposition which eventually forced the shah to leave Iran before Khomeini's triumphant return from exile.

During the shah's rule, he established close links with left-wing organizations, notably the Mujaheddin-e-Khalg guerrilla group and joined Mehdi Bazargan, the present prime minister, in establishing the Iran Freedom Movement to challenge the shah.

The combination of familiarity with the left and his Islamic training and religious status gave Ayatollah Taleghani a broader range of support than any other member of the clergy except for Iran's unofficial head of state, Ayatollah Khomeini.

In the aftermath of the revolution, that appeal broadened further to the ethnic minorities whose demands for autonomy he was willing to negotiate, not try to crush by military action. At the same time, his liberal stand on moral issues while the regime became steadily more fundamentalist endeared him to much of the middle class.

The breadth of his political support gave the ayatollah a political significance far above his rank in the religious hierarchy and a position for which there is no immediate heir.

Ayatollah Taleghani shared honors as the leading religious moderate with his clerical superior, Ayatollah Kazem Shariatmadari. But the latter is a somewhat retiring figure, and his political strength rests largely on support from his home province of Azerbaijan.

It was no surpise when Ayatollah Taleghani was proposed by the Mujaheddin as a candidate for the presidency of the Islamic Republic, but he resisted, saying clergymen should not hold political office.

The closest he came to this was a member of the secret but all-powerful Revolutionary Council.

Within weeks of the Revolutionary Council's establishment Ayatollah Taleghani is understood to have boycotted its sessions in the first evidence of serious differences among the leading clergy.

The differences exploeded into public view when Ayatollah Taleghani quite Tehran in early April to protest the arrest and beating of two of his sons and a daughter-in-law by revolutionary militiamen, In a major speech, he warned the country of the dangers of returning to "dictatorship and despotism."

The row appeared to set him on a collision course with Ayatollah Khomeini and risk a major split in the new regime.

But after several days of silence, he emerged from talks with Ayatollah Khomeini affirming his full support for the revolutionary leader and never again stepped out of line with policy decreed from the holy city of Qom.

In recent weeks, Ayatollah Taleghani suprised many Iranians with sharp criticism of his former allies on the left and of autonomy-seeking Kurds for whom he had acted as a sympathetic mediator.

But his enduring popularity was fully demonstrated during elections to the Council of Experts which was appointed to review the constitution. He won more votes than other candidate.