Iranian President Abol Bani-Sadr Tuesday declared a victory for government attempts to rid the campus of Tehran University of leftist groups and proclaimed a "great cultural revolution" designed to spread Islamic ideology through all spheres of Iranian life.

Spearheaded by fundamentalist student groups, Bani-Sadr's Moslem clerical rivals had made Iran's universities a battlefield last week in their efforts to revamp Iranian society and undercut Western-educated leaders such as Bani-Sadr.

Revolutionary Guards and Moslem fundamentalist students succeeded during the night in ousting the last remaining leftists from Tehran University in fighting that left at least three persons dead and hundreds injured over several days.

[The official Pars news agency said Tuesday that 10 persons were killed and more than 150 wounded as violence between rival student groups spread to several provincial universities, United Press International reported.]

In aligning himself and his government with the Islamic drive, Bani-Sadr appeared to be trying to take the issue away from his clerical rivals within the Revolutionary Council.

Iranian and foreign diplomatic analystss cautioned, however, that in putting himself in the forefront of an intensified Islamic crusade and temporarily consolidating his position, Bani-Sadr risks driving leftist guerrilla groups back to the urban terrorism that they used to combat the reign of the deposed shah, Mohammad Reza Pahlavi.

Coming on top of Iran's other numerous problems, a wave of ideological strife in the Persian heartland could over time be expected to weaken Bani-Sadr's authority.

All this points to continuation of a slowly deteriorating domestic political situation, but analysts generally agree that the latest events hold no immediate threat for the American hostages. Their detention by militant Moslem students appears to be a separate issue, and relative to the domestic turmoil erupting around it, has taken on a certain stability.

Bani-Sadr's government does not appear to be in immediate danger of collapse, and Iran's leftists currently do not seem capable of an armed uprising that would bring it down. As long as this country's revolutionary leader, Ayatollah Ruhollah Khomeini, remains alive, he is likely to retain the absolute obedience of millions of Iranians and thus the ability to overwhelm the left by calling his followers out en masse.

"The leftists probably realize that they can't take to the streets or they'd be beaten to death," one diplomat said.

"They don't stand a chance if they come into the open as an organized group. But if no political outlet is possible, there's only one other option, and that's terrorism."

Generally considered a moderate who favors a pluralistic approach to domestic politics, Bani-Sadr initially surprised Iranian and foreign observers here by coming out so strongly in support of efforts by right-wing Moslem students to purge universities of leftists, stamp out "Western influences" on the campuses and launch an "Islamic cultural revolution."

However, like the Nov. 4 U.S. Embassy seizure by like-minded Moslem students, the takeover of several colleges last week clearly had the backing of Khomeini and may well have been indirectly instigated by him. Thus, if he had resisted the action, Bani-Sadr might have been outpaced again by the Moslem hard-liners as he has been on the hostage issue.

Khomeini left no doubts where he stood when he told representatives of Islamic student organizations yesterday that the country's universities "must be reconstructed from the beginning so that our youth have Islamic training."

In his speech, published here today, Khomeini railed against a university system that he said was established under Western influence. But his remarks were also apparently aimed against leftist organizations, such as the radical Islamic Mujaheddin and the Marxist Fedayan, which dominate political life on many political campuses.

Iranian youths should not be dependent "on the West, nor dependent on communism, nor dependent on Marxism" Khomeini said.

"We do not fear economic sanctions or military intervention," he said. "What makes us frightened is cultural dependence. We fear colonialist universities. We fear universities that train our youths to serve the West to serve communism."

Taking Khomeini's thinking a step further in his speech this morning at Tehran University, Bani-Sadr defined a cultural revolution that would not only instill Koranic precepts in society but would strengthen his own authority to crack down on labor agitators in Iranian industries, autonomy-seeking minorities and leftist-political opposition.

"The Iran of today needs an original and real cultural revolution," Bani-Sadr said. "The first principle of this revolution is that the government elected by you must be the executive force of the people. . ." He said the cultural revolution meant pushing farms and factories to greater production and pitting the Iranian masses against rebels in the troubled provinces of Khuzestan and Kurdistan.

"This revolution will power . . . is the beginning of an original and all-around revolution that will change the world," Bani-Sadr said.