A last-minute compromise between Sen. Dennis DeConcini (D-Ariz.) and the Senate leadership - reportedly endorsed by Panama - has apparently cleared the way for Senate approval today of the second Panama Canal treaty.

However, the final headcount remained so close that treaty supporters and Carter administration lobbyists avoided making any predictions last night.

The administration regards today's vote as vital to its ability to conduct foreign policy for the rest of President Carter's first term. Sen. Robert C. Byrd (D-W.Va.), the majority leader, said yesterday the vote "may well influence the course of world affairs . . . for generations."

The last-minute compromise involved the wording of a new declaration to be added to the second treaty reaffirming America's commitment not to interfere in the internal affairs of Panama.

The declaration was drafted by Byrd and other Senate leaders in close consultation with DeConcini. It was deemed necessary to reassure Panama that an earlier amendment to the first Panama Canal Treaty authored by DeConcini was not a departure from the principle of nonintervention.

Byrd discussed the wording of the new declaration with Panamanian officials over the weekend, and indicated to DeConcini and other colleagues yesterday that Panama approved the proposal and would accept the two treaties if the second one was amended to include it.

Byrd told reporters the Panamanians regarded his proposal as "a dignified solution to a difficult problem."

DeConcini said last night that he was "very satisfied" with the new declaration, not least because it was close to language he himself proposed to Byrd last Friday. He said he now expects to vote for the second Panama treaty today.

DeConcini had struggled with the Senate leadership for more than a week to get the word "open" into the declaration. He prevailed.

He said he wanted the new declaration to leave no doubt about the validity of his earlier reservation to the first treaty, which asserted a U..S right to intervene militarily in Panama to keep the canal "open" in the future.

The first treaty as amended by the Senate had said the United States had a right to act to keep the canal secure and neutral, but not open. DeConcini said the distinction was important to emphasize that the United States could act if the canal were closed, say, because of a labor dispute.

The new declaration, which will be sponsored by Byrd and co-sponsored by DeConcini and many other senators, will reaffirm the longstanding U.S. policy of non-interference in Panama's affairs, and will say that any action taken by the United States to exercise its rights under the treaty to keep the canal secure, neutral and open should not be interpreted as an infringement on Panamanian sovereignty.

In other words, the language is vague. "I don't think it does anything, and that's fine with me," DeConcini said last night. He added diplomatically, "other people may have another interpretation."

Senate leaders and the administration hope that the government of Panama will interpret this as the face-saving device it needs to accept the Senate's version of the treaties.

(Washington Post special correspondent Marlise Simons reported from Panama City last night that the government there will accept the new declaration).

During the negotiations that led to last night's compromise, DeConcini said, the Senate leadership resisted the use of the word "open," at least until last Friday.

Besides Byrd, the senators negotiating with DeConcini included Alan Cranston (D-Calif.), the assistant majority leader; Frank Church (D-Idaho), floor manager of the canal treaties, and Paul S. Sarbanes (D-Md.), who has acted as Church's principal associated during the long debate.

The Carter administration was largely excluded from the last stages of bargaining. After a final meeting late yesterday between Byrd and DeConcini at which the compromise was agreed to, administration lobbyists had to wait about 20 minutes to get a copy of the final wording from Byrd's office.

Byrd declined to release the text last night, reportedly because he thought potential critics of it would have less opportunity to snipe at the wording if they had to wait until today to see it.

There appeared a good chance last night that the second treaty, spelling out terms of the turnover of the canal to Panama, would be approved by the Senate by the same 68-to-32 vote as the first, which established the permanent neutrality of the canal.

However, the treaty's backers were concerned about at least two senators who voted "yes" on the first treaty but have now threatened to change their minds.

One, Sen. S. I. Hayakawa (R-Calif.), met with President Carter yesterday to discuss the issues troubling him. Hayakawa suddenly began to complain Friday that the administration's foreign policy was too "weak," and he was reconsidering his support for the canal treaties. He would not say last night where he now stands.

Sen. James Abourezk (D-S.D.) has also threatened to change his "aye" vote to "no" out of pique at the administration's secretive bargaining to get a compromise energy program through Congress.

Sen. James R. Sasser (D-Tenn.) is also reported to be angry at the administration over other issues, but treaty backers said his vote was still in the "aye" column on the Panama treaty.

Several liberal senators who opposed the original DeConcini reservation as unfair to Panama have apparently accepted yesterday's compromise declaration as sufficient to mitigate the impact of the earlier DeConcini change.

DeConcini himself has offered two more relatively minor changes to the second treaty, and said yesterday he would vote "yes" provided both are adopted today.

The final vote on the second treaty is scheduled for 6 p.m. today.

When the Panama debate began in early February there was snow on the ground on Capitol Hill. As it drew to a close yesterday amid the green of a new spring, the Senate adopted two substantial reservations to the treaty under consideration.

One effectively nullifies the provision in the treaty that had committed the United States to build any future Central American canal in Panama, and committed Panama not to let any other country build a new canal on its territory. This was an idea hastily adopted by Carter last summer in the closing weeks of the treaty negotiations, one which Panama never much liked.

The second reservation adopted yesterday states that the United States cannot be held liable for payments to Panama that are supposed to be made out of canal toll revenues if those revenues fall short of expectations or needs.