President Abol Hassan Bani-Sadr fought until early today to persuade Panama to prevent the deposed shah of Iran from leaving for Egypt, lost and then predicted his presence would prove a "poisoned gift for President Anwar Sadat.

In a desperate effort to allow Tehran's extradtition case against the shah to go forward as planned later today, Foreign Minister Sadegh Ghotbzadeh said he had promised to transfer the estimated 50 American hostages from the custody of their militant Islamic student captors to government control by midnight Panama time.

Other sources said, however, that the Iranians had promised only to let the Panamanians know by then if they would agree to the transfer.

In any case, informed sources present at a meeting at Bani-Sadr's office said that former Panamanian president Omar Torrijos had told the Iranians by telephone, "I cannot wait one minute longer."

He was said to have added, "I don't have the economic or political means to stand up to threatened reprisals" from David Rockefeller, chairman of the Chase Manhattan Bank, and former U.S. secretary of state Henry Kissinger.

Torrijos' reported comments followed statements Saturday by Iranian Foreign Minister Sadegh Ghotbzadeh that Kissinger and Rockefeller were behind a secret plan to stop extradition proceedings against the shah. There was no independent confirmation of Ghotbzadeh's accusation, nor of Torrijos' remarks.

During the course of the evening the Iranians talked twice to Torrijos, the Panamanian strongman, and four times to Juan Materno Vasquez, the Panamanian lawyer who was to have presented Iran's case demanding the shah's extradition this morning.

Ghotbzadeh said that Panama had given Iran a 24-hour ultimatum "knowing we did not have a possibility of carrying out what they asked" -- by inference, letting the shah leave the country if control over the hostages were not shifted.

In fact, Torrijos apparently shortened the time period, since the shah left well before the apparent ultimatum was to have expired at midnight Panamanian time, informed sources said.

At 3 a.m. Ghotbzadeh, after yet another telephone conversation with Panama, reportedly said, "In order to show good faith I declare that if the ex-shah is arrested when he makes a fueling stopover [on his way to Cairo] and is returned to Panama for the extradition procedures, the transfer of the hostages will be met within 24 hours."

As has been the case since the hostages were seized last Nov. 4, Iranian revolutionary leader Ayatollah Ruhollah Khomeini once again did not want to be mixed up in the negotiations, according to informed sources.

Earlier, informed sources reported that Sunday morning Ghotbzadeh had visited Khomeini to inform him of the Panamanian positon. The ayatollah's son, Ahmad, reported that the problem was "85 percent settled," the sources said. But the Iranians argued that they needed until Monday afternoon Tehran time to work out details of the transfer with the students.

Left unsaid was the apparent attempt by the United States and Iran to take advantage of the torpor of the week-long Persian new year to work out the transfer of the hostages.

Only two weeks ago a similar effort fell apart when the militants at the embassy enlisted Khomeini's support and prevented a United Nations commission from visiting the hostages.

Once the commission had left Iran, the United States, according to some analysts here, apparently felt under no obligation to go along with the related question of allowing the extradition proceedings in Panama to go ahead.

The latest turn of events seems to have further imperiled the already endangered positions of both Ghotbzadeh and Bani-sadr, the only major Iranian political figures who have been willing to fight for a rapid solution to the hostage crisis.

Ghotbzadeh insisted that when Kissinger and Rockfeller realized Iran had a solid extradition brief to present, they "asked President Aristides Royo to let the shah go."

The foreign minister also said Panamanian officials tried to avoid the extradition proceedings by saying that their law ruled out extradition if the person to be returned faced the death peanlty.

"I said when the moment comes we will be disposed to promsie not to execute the shah," Ghotbzadeh recalled.

He said the Panamanian government decided to let the shah go to avoid "having to arrest him tomorrow morning" and avert setting off a "big political fight in Panama."

The minister apparently was alluding to Panamanian law, which he claimed made the shah's arrest mandatory if the Panamanian government had agreed to start extradition proceedings.He did not elaborate on his remarks about the political argument inside Panama.

Ghotbzadeh renewed his charges that Kissinger had spent three days recently in Panama where he conferred "at length" with Royo after previously meeting with the law firm of Morgan and Morgan. That firm, he said, represented Kissinger, Rockefeller and the shah in Panama.

Paradoxically, Bani-Sadr and the militants at the embassy, whom he has consistently denounced as a rival "power center," found themselves agreeing about the shah's departure for Egypt.

"The shah [remains] in the hands of the United States," the president said. "There is no difference for us between Panama and Egypt since both are close to the White House," he added. "I can say Sadat is closer to the White House than Royo."

The militants, who have repeated their unchanging demands for the shah's extradtition and the return of his wealth from the United States, said the deposed monarch's "leaving Panama is not important."

If he "goes to the Bahamas, Egypt or any other American colony," they added, it "is not important."

The students, who promised a formal statement later in the day insisted that they wanted a "revolutionary" extradition procedure "not through compromise or in the way Mr. Ghotbzadeh is tryng."

They said, "We are sure that Mr. Ghotbzadeh's way to obtain the shah's extradtion would be impossible."

Bani-Sadr said the shah's departure "showed the humanitarian aspect of the hostages [situation] is secondary and what is most important to the American government is to make political war against us. They [the Americans] want to weaken our revolution."

The news of the shah's departure from Panama was broadcast on the midnight Tehran radio news and quoted the American television network ABC. m

Significantly, in view of the recent harsh attacks against the Soviet Union delivered by both Khomeini and Bani-Sadr, the radio also quoted the Soviet news agency Tass.

Tass was quoted as saying, "This is a new game from the American side to stop the extradition of the shah to Iran. It had a direct relationship with the facts of the ravages of imperialism in Iran and the close ties of the United States and the former regime."