President Carter and Panama's Gen. Omar Torrijos agreed yesterday that the Panama Canal treaties give the United States a permanent right to take action - including the use of military force - against threats to the waterway.

he agreement, worked out at a lengthy White House meeting between the two leaders, armed Carter with a powerful new weapon in his struggle to wring approval of the treaties from a divided Senate.

The fate of the agreements, which would turn eventual control of the canal over to Panama, had been jeopardized by concern about differing U.S. and Panamanian interpretations of what future defense rights the United States will have in the canal.

Prompting the Senate's concern were statements by Panamanian officials implying that the treaties do not give the United States rights to protect the canal through military action and to obtain priority passage for U.S. vessels in time of war.

The Panamanian statements were aimed at countering charges by Torrijos' domestic critics that the United States had been given too many concessions in the treaty negotiations. In paraicular, Panamanian nationalists have argued that the United States might intervene in Panama's internal affairs under the guise of using its forces to protect the canal.

On Tuesday, several senators warned Carter that the agreements had no hope of winning the required 67 votes - two-thirds of the Senate - unless these differences were clarified in ways that spelled out U.S. rights clearly.

The result was a hastily arranged visit to Washington by Torrijos, pana ma's military ruler, and the hammering out of a joint U.S. panamanian statement that was made public last night.

On the question of U.S. military action, the statement notes that the treaties give Panama and the United States joint "responsibility to assure that the Panama Canal will remain open and secure to ships of all nations."

It then adds: "The correct interpretation of this principal is that each of the two countries shall, in accordance with their respective consitutional processes, defned the canal aginst any threat to the regime of neutrality, and consequently shall have the right to act against any aggression or threat directed against the canal or against the peaceful transit of vessels through the canal."

On the question of what the treaty tex calls "expenditious passage" for U.S. warships, yesterday's statement said:

"This is intended, and it shall so be interpreted, to assure the transit of such vessels through the canal as quickly as possible, without any impediment, with expedited treatment, and in case of need or emergency,to go to the head of the line of vessels in order to transit the canal rapidly."

To shield from charges that the U.S. right to protect the canal through military action could lead to unwarranted interference in Panama, yesterday's statement also contained this language:

"This does not mean, nor shall it be interpreted as right of intervention of the United States in the internal affairs of panama. Any United States action will be directed at ensuring that the canal will remain open, secure and accessible, and it shall never be directed against the territorial integrity or political independence of Panama."

The statement was not signed by the two leaders. But reliable sources said they laid down the general outline of what wad to be included and then turned the actual drafting over to two of the original treaty negotiatiors: Sol M. Linnowitz for the United States and Romulo Escobar Bethancourt for Panama.

"There has never been any misunderstanding between President Carter and Gen. Torrijos as to the exact meaning of the treaties," Linowitz told reporters last night."The statement is intended to put to rest any misunderstanding as to what is intended under the treaties."

Despite Linowitz's optimism, though, it was not immediiately clear last night whether the statement would achieve its intended effect, either in the United States or in panama, where a national plebiscite to ratify the treaties by vote is scheduled for Oct. 23.

Torrijos, who returned to Panama last night, told reporters before his departure that he was satisfied with the clarification. He summarized its meaningg in this way:

""If a great power attacks the canal or puts the canal in dander, it is the right of the United States to go and defend the canal. But it does not have the right to intervene or interfere in the internal affairs of Panama."

on the U.S. political front, Linowitz went to Capitol Hill before the statement was made public to brief members of the Senate Foreign Relations Committee on itsss contents.

Following the briefing, most committeee members were unavailable or unwilling to comment on the statatatment until they had studied it more closely. However, committee sources said the dominant tone in the meeting seemed to be a feeling that the statement marked a significant step toward clearing up the disputes over interpretation.

But, the sources added, some senators expressed reservations about whether language in the statement concerning the "territorial integrity" of Panama might be a restraint on U.S. military action. Other senators, the sources said, also questioned whether the statement was sufficient, since it is not a part of the treaties and apparently does not have any binding legal effect.

one senator who did comment, Richard B. Stone (D-Fla.), called the statement "a major step" that goes "a long way toward reducing the confilicts." But Stone also noted that "this statement alone does not carry the force of law" and might "have to be made the subject of an understanding or reservation by the Senate to be binding legally."