The Senate yesterday defeated efforts to prohibit the Central Intelligence Agency and Defense Department from handling aid to rebels fighting the government of Nicaragua but voted to require compliance with international law in use of the funds.

The Senate also reaffirmed its opposition to extending a ban on use of U.S. funds for military or paramilitary aid to the contras, or counterrevolutionaries, fighting the leftist Sandinista government.

The actions came as the Senate completed voting on a plan for $38 million in nonmilitary aid to the contras. It is included in a fiscal 1986 State Department authorization bill that is expected to win final approval Monday.

As part of the authorization bill, the Senate voted overwhelmingly to reduce the U.S. contribution to the United Nations and its agencies from its current level of 25 percent of all nations' contributions to 20 percent of the total.

The Senate approved similar but less drastic cutbacks in 1983 and 1984.

The action last year resulted in a one-year freeze on U.S. contributions, according to the office of Sen. Nancy Landon Kassebaum (R-Kan.), sponsor of the proposals.

The Senate-approved cutback for next year could be avoided only if the United Nations reduces salaries of its personnel to the levels of U.S. civil service employes and gives member nations a proportional vote on budget matters.

As the Senate struggled for a second day with the contra aid issue, the question of compliance with international law caused the greatest controversy.

Action was stalled for several hours as Republican leaders wrestled with Reagan administration objections and a spat over a Democrat's insistence on a roll-call vote on the issue.

Sen. John F. Kerry (D-Mass.) appeared to be on the verge of winning the only Democratic victory in restricting use of the aid money when Senate Foreign Relations Committee Chairman Richard G. Lugar (R-Ind.) agreed to accept his proposal to ban use of funds for activities that would violate international law or the charter of the Organization of American States.

Then the administration raised objections, and Kerry demanded a roll-call vote, angering Majority Leader Robert J. Dole (R-Kan.), who wanted to dispose of the issue on a less conspicuous voice vote.

At that point, things began to unravel. Dole, grim-faced, sought reconsideration of the vote, and the Senate agreed, on a basically party-line vote of 48 to 42.

After several hours of off-the-floor huddles, Kerry's proposal was approved on a voice vote after he met administration objections by agreeing to language sanctioning congressionally authorized activities that might violate international law, such as aerial surveillance over foreign countries.

Although Dole and other Republicans said Kerry's proposal would have little if any effect, Kerry said after the vote that it could be "an important piece of leverage" to assure that the so-called humanitarian aid for contras would not be used for covert military purposes under CIA direction.

It would cast doubt on legitimacy of the current U.S. economic embargo against Nicaragua, he said, although the Senate voted, 65 to 22, earlier in the day against a proposal by Sen. Alan J. Dixon (D-Ill.) to end the sanctions.

If the government goes beyond purely humanitarian aid in using the $38 million, the provision might be invoked in court to block such activities, Kerry added.

But Kerry acknowledged being disappointed by the closeness of the vote on adherence to international law. "It is a less than ringing message," he said.

The proposal to ban the CIA and Defense Department from handling the new aid money was offered by Sen. Tom Harkin (D-Iowa) and rejected, 62 to 30. Harkin had said the move was to bring the Senate measure in line with a Republican plan expected to reach a vote in the House next week.

A Harkin proposal to keep current restrictions against use of funds to support military or paramilitary operations against Nicaragua was rejected, 57 to 35.

Kassebaum's proposal to cut U.S. spending on the United Nations was approved, 71 to 13.

In arguing for her proposal, Kassebaum said U.N. costs increased by 273 percent between 1972 and 1982, in part because of what she called "bloated" salaries of its employes. She cited the case of an undersecretary-general of the United Nations who recently retired with a $400,000 lump-sum payment and tax-free annual pension of $50,000 and was rehired as a consultant at about $90,000 a year, also tax free