It was late Tuesday night, following a long direct flight to Panama city, that White House chief of staff Hamilton Jordan sat down with Gen. Omar Torrijos to plead for Panamanian acceptance of the shah of Iran.

Torrijos' response was immediate. The deposed shah was welcome, he said, and there were "no conditions" on the length of his stay.

Reached by telephone in Panama yesterday, the former military head of state -- who retains behind-the-scenes power on foreign policy matters although he stepped down last year in favor of handpicked civilian President Aristides Reyo -- said he could not comment on the negotations that led to the Shah's arrival there.

But a close associate who knows his thinking on the subject said Torrijos wanted to make "a gesture of friendship to the United States" that would be reciprocated with respect and would put an end to the "growing craziness in the world" as a result of the U.S. Iranian crisis.

The source insisted that Panama had made no demands in return for the shah's admittance and did not expect to gain from his considerable fortune. "We hear he's very stingy," the sources said.

As for possible diplomatic problems or domestic protests, the source said, "there is no atmosphere for conflict here," over the arrival of the shah and noted that Panama has no embassy in Tehran.

Flown to Panama early yesterday morning from Texas the shah was taken by helicopter to the Pacific resort island of Contadora, 35 miles southwest of the capital. The source said he has been ensconced in the vacation home of former Panamanian ambassador to the United States Gabriel Lewis, where he is expected to stay indefinitely.

The source said the shah had brought only "one Persian colonel" with him, as well as a contingent of privately hired American bodyguards who would "guard his front door." Security around the island, the source said, would be provided by "the Panamanian nation."

Little public resource to the shah's presence was reported in Panama. Royo, who received a telephone call from President Carter thanking him for admitting the deposed Iranian leader, said in a television interview that the shah's stay "will not cost the Panamanian people anything. Panama is a hospitable country, and the shah will be well received. He will not be a cause for problems in Panama."

Although Royo, who spent yesterday visiting the far western Panamanian city of David, was consulted on the descision to admit the shah, sources in Washington said it was made by Torrijos.

For those who know Torrijos, his acceptance was not surprising. "The general," as he is known to Panamanians, makes decisions quickly. He enjoys being a prominent actor in the international arena, a role he has had few opportunities to play since his ostensible retirement from political power in October 1978.

Although Torrijos remains commander of the Panamanian National Guard, he technically has no role in the civilian government.

Two weeks ago, Mexican President Jose Lopez Portillo upset U.S. hopes of securing the release of 50 hostages held in Iran by refusing to readmit the shah, who had been living in Mexico.

Torrijos, sources said, decided to admit the shah because he wanted to teach a lesson in "friendship" to the United States, whose Congress accused him of everything from drug trafficking to communism in its debates over the recently implemented Panama Canal treaties.

Torrijos reportedly developed a deep respect for Carter during the final step of the documents before they were debated in Congress. Those close to him say he believes that Carter fought hard for passage of the treaties and staunchly defended him against the attacks on him personally and his politics, despite Carter's own political risks.

During the congressional debates, Jordan served as Carter's personal emissary to Torrijos, and made several trips to consult directly with the Panamanian leader. Sources said Torrijos has a great fondness for Jordan, whom he calls "Hamilton," and that Jordan's late-night appeal for Panama's aid was delivered on a highly personal basis.

Panama initially offered political asylum to the shah last spring, when several of his emissaries scouted for potenial residences there before a decision was made to go to Mexico. That same invitation, the Panamanian source said yesterday, was never rescinded.

"We have to be sympathetic to the sadness of [the shah's] position," the source said. "This is the first smile he's seen in a long time." Although some Panamanians speculated that the shsh, who is suffering from cancer, was not expected to live much longer, the source said Torrijos had spoken with the shah's doctor and been told "he looks okay."

Asked whether Torrijos' own self-declared revolutionary credentials would be tarnished by accepting the enemy of the Iranian revolution, the source described the shah as "progressive, compared with [Iranian leader Ayatollah Ruhollah] Khomeini."

Panama appeared to be anxiously awaiting both the U.S. and Iranian responses to yesterday's events. Noting that the United States "is showing its respect for our decision," the source asked if the American people felt relieved.

Told that Iranian students holding the American hostages have said the shah's departure from the United States made "no difference" to their demands for his return to Iran, the source replied, "That's good, at least they haven't done anything violent."

Contadora Island, the shah's new refuge, is part of the Pearl Archipelago, a group of small hilly islands in the Pacific Ocean. Developed as a posh, expensive resort, it has a small airstrip, one large hotel and a number of exclusive residential villas often used by high government officials.

At least one round of Panama Canal treaty negotiations with the United States was held on Contadora. Isolated and peaceful, the island is believed easily defended from land or sea incursion.