The Senate yesterday agreed to hold a final vote on the Panama Canal treaty April 18 after rejecting a key opponent's amendment by a large margin.

The final vote is to come in the ninth week of debate on the Panama treaties. The debate has taken up more of the Senate's time than any treaty issue since 1919-20, when American membership in the League of Nations was at issue.

A major treaty opponent, Sen. Jesse A. Helms (R-N.C.), indicated some pessimism about the prospects for defeating the second treaty yesterday. He said he could just 31 firm votes against it, and 34 would be needed to defeat the treaty if all 100 senators vote.

The first Panama pact carried 68 to 32.

Yesterday's 56-to-37 rejection of a key amendment offered by Sen. Orrin G. Hatch (R-Utah) was an unexpected disappointment to the treaty opponents.

Hatch has argued for months that the Constitution requires action by both the House and Senate before the Panama Canal can be transferred to Panama, since it is government property. His amendment incorporated this idea.

An hour or so before yesterday's vote, aides in Helms' office were telling assistants to other senators that they had 48 firm votes in favor of the amendment's backers circulated reports that they had at least 45 votes.

But in the end the Hatch proposal got fewer votes than half a dozen opponents' amendments had received earlier, a weak showing. Afterward Senate Majority Whip Alan Cranston (D-Calif.) issued a statement saying he was "much more confident saying he approval of the second treaty."

Hatch disagreed, however, and quickly issued a news release under the heading: "Hatch Calls Defeat a Victory." He argued that 34 needed to block the second treaty, therefore a favorable sign for his side.

But even his colleague, Helms, took another view yesterday. Helms said it appeared to him that pressure applied to senators by treaty opponents during the recent Easter recess had not changed any minds on the second treaty.

The second treaty spells out the way the United States would turn the canal over to Panama by the year 2000. The first treaty, already approved, committed both countries to maintaining the neutrality of the canal idefinitely, and set out U.S. rights to intervene militarily to defend that neutrality.

Several senators who were targeted by conservative groups during the recent recess said in interviews that they were surprised that they did not hear more from antitreaty contstituents while they were at home.

Sen. Dennis DeConcini (D-Ariz.), for example, who provided a key vote in the "aye" column on the first treaty, said he expected to encounter more hostility from voters than he found.

Helms said yesterday, "I think the more quickly we vote, the better it will be for our side." Until now the treaty opponents have taken the view that prolonged debate might win over enough snators to block the treaty.

Under the schedule approved late yesterday by unanimous agreement, the Senate will consider amendments to the second treaty between now and April 13, then will debate a resolution of ratification until 6 p.m. on the April 18, when the final vote is to be held.

The schedule agreed to includes specific time to consider three amendments, two of which have a good chance of being adopted by the Senate.

One, sponsored by Sen. Bob Dole (R-Kan.), would eliminate the article of the treaty that would commit the United States to build a new, sea-level canal in Panama if it decides such a canal is needed. The article also would bind Panama not to allow any other country to build a new canal on Panamanian territory.

Many senators have objected to this proposal, which was inserted in the treaty at the end of negotiations at the insistence of President Carter. The Panamanians have never been enthusiastic about it.

A second amendment that could be approved, Senate esources say, is one sponsored by Dewey F. Bartlett (R-Okla.), stating that the United States cannot be held liable for any money due Panama under the treaty that is supposed to come from tool revenues, if those revenues prove inadequate.