Justice Department investigators have uncovered documents that apparently link the Iranian embassy in Washington to the transfer of millions of dollars into the United States to pay for the pro-shah demonstrations that erupted in violence here in November 1977, U.S. and Iranian sources have disclosed.

The documents, including bank records, are being presented to a grand jury in Chicago that is investigating payments, made to U.S. citizens and Iranians in the demonstrations, for possible violations of federal exchange control and foreign agents' registration laws, the sources said.

Iran's embattled ambassador to the United States, Ardeshir Zahedi, and his chief aides possess diplomatic immunity, and could not be charged by the grand jury. But the line of investigation pursued by the Justice Department suggests that some Iranian diplomats could be listed by the grand jury as unindicted coconspirators, according to sources close to the investigation.

The White House, acting through the State Department, has expressed concern to Justice over the possible impact of the politically explosive investigation on U.S.-Iranian ties, according to these sources, who say they feel that national security grounds may be invoked in an effort to block the case from coming into open court.

One administration concern is reported to be that a trial could expose sensitive information on links between the shah's secret police, SAVAK, and the Central Intelligence Agency. Iranian diplomats who have broken with the shah and Zahedi claim that the embassy is staffed by SAVAK agents.

The State Department yesterday acknowledged that it had been consulted by Justice on the Chicago grand jury investigation, but would offer no additional comment.

Although the primary focus of the grand jury hearing appears to be elsewhere, the Justice Department investigation has probed the activities of an Iranian-funded, New Youk-based foundation represented by former president Richard M. Nixon's secretary of state, William P. Rogers, U.S. and Iranian sources said.

Rogers is a director of the Pahlavi Foundation. He said in a telephone conversation yesterday that his New York law firm represents the foundation in its legal matters, but he declined to discuss directly whether the foundation had come under scrutiny in the Justice Department investigation.

Any such scrutiny would have shown that the foundation was blameless, Rogers said.

The primary targets of the grand jury hearing are reported to be large numbers of middlemen who helped assemble and pay thousands of demonstrators to show support for Shah Mohammad Reza Pahlavi when he visited Washington on Nov. 16, 1977.

Federal investigators have subpoenaed bank records in New York to discover if the money the intermediaries used was channeled from Tehran through embassy staff members. Many of the intermediaries were connected with Armenian, Assyrian or Iranian heritage and friendship groups in Illinois and California.

Federal law requires foreigners or U.S. citizens acting on behalf of a foreign power to register as an agent if they engage in lobbying and political activity.

Officials of the New York branch of the Bank Meli, a government-owned Iranian bank, yesterday declined to discuss the subpoenas. "It is a delicate matter," one official said.

Zahedi, who leaves his post Feb. 17 to join the shah in what appears to be political exile in Morocco, could not be reached for comment this week. A spokesman for the embassy said the ambassador had no knowledge of any investigations into the financing of the 1977 demonstrations.

The unraveling of the shah's rule in Iran over the past year has brought turmoil to the embassy here and ended the tenure of Zahedi. Until a few months ago, he was one of the most powerful men of his country and one of the most courted diplomats in Washington, where his lavish entertaining coused society columnists to dub him "the golden boy" of diplomatic row.

Details of the investigation in Chicago, as well as other controversial embassy activities, are filtering out in the wake of the breakup of his embassy here. At least six Iranian diplomats have thrown in their lot with Ayatollah Ruhollah Khomeini's "revolutionary government," and a similar number have walked out rather than continue to serve with Zahedi.

Some of the dissident diplomats claim that large numbers of embassy documents have been shipped out of the embassy to Zahedi's residence in Switzerland in recent months. The documents involve covert activities by SAVAK and contain information on the 1977 demonstrations, the dissidents say.

Fearing reprisals, these sources asked to remain anonymous.

Ali Akbar Tabatabai, Zahedi's press counselor, called the assertions lies. He said that cartons recently shipped by the embassy to Zahedi's Swiss home contained only the ambassador's clothing and personal effects.

Zahedi's direct access to the shah, who was once Zahedi's father-in-law, gave him enormous clout in Washington, and his name has been frequently linked with the capital's most important politicians, diplomats, journalists and others.

He was in frequent contact with Henry A. Kissinger and with Zbigniew Brzezinski, President Carter's national security adviser, as the crisis turned against the shah last fall. According to one former aide, Zahedi constantly told the shah that these contacts, and his multimillion-dollar entertainment budget at the embassy, showed that "The U.S. is with you all the way and you should be firm."

As pieced together from U.S. and Iranian sources with knowledge of the Justice Department investigation, the events that led to the November 1977 demonstrations were set in motion by an order from the shah to SAVAK to make sure that the monarch was greeted by friendly demonstrations when he traveled abroad.

Maj. Gen. Mokhateb Rafii, who is reported to be SAVAK's Washington station chief, was convinced by failures elsewhere to turn to a "rent-a-crowd" approach, according to diplomatic sources Rafii is officially head of Zahedi's secretariat at the embassy.

Justice Department investigators have looked at tow multi-million-dollar transfers from Tehran to the Bank Meli in New York and then to Rafii's Washington bank account shortly before the demonstrations, according to sources close to the investigation.

The investigators have reportedly been told that Rafii paid some intermediaries by check and handed out cash to many others, who in turn reimbursed the demonstrators for travel and hotel expenses and gave them $100 or $200 as "pocket money."

According to dissident diplomats, the embassy directly paid the hospital bills of Iranian military cadets who were injured in the demonstrations, and also reportedly paid for and controlled ticket distribution for dinners to which members of Congress were invited. Nominally, the dinners were staged by nonembassy organizations.

Rafii and military attaches took over the embassy last week during a dispute with the charge d'affaires in Zahedi's absence. Since returning from Morocco Tuesday, Zahedi has sought to dismiss or put on leave most of the embassy diplomatic staff, which is in revolt against his continued presence in washington.

Khomeini, the Moslem religious leader who spearheaded the protests that drove the shah from Iran Jan. 16, has appointed an interim committee to look after the embassy, but the committee's members say they will not use physical means to oust Zahedi and his aides.