Ernest W. Lefever, President Reagan's controversial nominee to head the U.S. human rights program, yesterday went through a stormy confirmation hearing that saw Democratic senators attack him as a hard-line anti-communist who seems unconcerned about rights abuses in non-Marxist countries.

In addition, the hearing by the Senate Foreign Relations Committee produced a lengthy wrangle about whether Lefever would allow the committee to examine records of financial contributions to a public policy center he heads to try to determine whether he was given support by the white-dominated government of South Africa.

Lefever who denied the charge under oath, at first refused to hand over the records, on the grounds that he had a legal obligation to protect the privacy of the contributors.

Lefever finally bowed to the repeated complaints of chairman Charles H. Percy (R-Ill.) and other members about his lack of cooperation and promised to give the records to the committee under an arrangement that will limit access to Percy, Sen. Claiborne Pell (D-R.I.), the ranking minority member, and four committee staffers.

Even with this concession, the acrimonios tone of the questioning left the distinct impression that a majority of the committee is inclined to vote against confirming Lefever as assistant secretary of state for human rights. Even if the panel does not report his nomination favorably, he can be confirmed by the full Republican-controlled Senate.

Lefever's testimony clearly failed to dent what appears to be solid opposition from Democratic committee members, and at least two of the majority Republicans -- Percy and Sen. Rudy Boschwitz (Minn.) -- seemed from their comments to have serious doubts about Lefever's commitment to an activist human rights policy.

Percy wound up delivering an impassioned lecture to Lefever about the need for an activist policy.

Seizing on Lefever's repeated statement that he wants "to nudge history," Percy said: "It's important to do more than nudge history. . . . We want an advocate, a spokesman who is looked to as a leader in world opinion in the fight for rights. . . ."

Lefever was questioned particularly strongly about the relationship between the Nestle Co. and the Ethics and Public Policy Center, the private nonprofit foundation Lefever headed at the time it contracted for a study on marketing infant formula in Third World countries.

Lefever was forced to admit that, although the study was never completed, the center received a $5,000 contribution from Nestle at precisely the time it was to pay that amount to the proposed study's author. The same author later did an article on the subject for Fortune magazine, and the center reprinted the article.

Lefever also admitted that Nestle, which reportedly considered the article favorable to its cause, contributed an additional $20,000 to the center at the time of the reprinting.

"It is the policy of the center not to accept contributions for specific projects in which the donor has a direct financial interest," Lefever said.

However, in a dramatic conclusion to the first day of hearings and after aggressive questioning by Sen. Christopher J. Dodd (D-Conn.), Lefever admitted that immediately after the $20,000 contribution his center conducted a "large mailing" to a list of community leaders provided by a public relations firm to whom he had been referred by a "friend."

Lefever responded only partially to each of Dodd's questions and, when asked for the name of the "friend," he appeared flustered, asked for a recess and rushed from the hearing room.

Regaining his composure after a break, Lefever admitted that the "friend" who referred him to the public relations firm was Thomas Ward, a Washington lawyer for Nestle. Lefever admitted he did not know Ward very well.

Lefever, whose criticism of former president Carter's approach to human rights has caused many liberal organizations active in the rights field to oppose his nomination, also sought yesterday to dispel the notion that the Reagan administration is indifferent to rights abuses, except as a tool for attacking the Soviet Union and other communist regimes.

Asserting the administration's intention to be evenhanded, he said: "We must recognize, and this I wish to underline, that there is only one moral yardstick. Tortune, internal exile, summary executions, harsh emigration restrictions are always deplorable whether committed by friend, foe, or neutral, by a totalitarian, authoritarian or democratic regime."

But, he added, "We must recognize that there are moral and political limits to what the U.S. government can and should do to modify the internal behavior of another sovereign state."

There might be times, Lefever conceded, when rights violations will be "so egregious" that the U.S. government will consider it necessary to speak out publicly in condemnation. However, he insisted repeatedly that he believes the "quiet diplomacy approach," conducted away from the public eye, tends to influence other governments more effectively.

Lefever continually answered questions by saying that he had yet to conduct a review of human rights legislation, policies and practices, including whether there is a need for the office.

Calling himself "a confirmed do gooder," Lefever, an ordained minister of the Church of the Brethren as well as a scholar and writer, asserted, "My whole life has been oriented around human rights and humanitarian affairs."