Ernest W. lefever withdrew yesterday as President Reagan's nominee to be the chief U.S. spokesman on human rights after the Senate Foreign Relations Committee spurned Reagan's appeals and rejected the nomination, 13 to 4.

Several hours after the vote, Sen. S. I. Hayakawa (R-Calif.), who had been scheduled to lead the administration's fight on the Senate floor to overturn the committe action, made public a letter from Lefever to the president.

Lefever referred bitterly to the criticism triggered by his nomination to the State Department post and said:

"I am blameless of the charges and innuendoes against my integrity and compassion. I do not wish any longer to put up with the kind of suspicion and character assassination that some of my adversaries have used to besmirch my name."

His withdrawal, although a blow to the administration's prestige, averted what could have been an even greater embarrassment for Reagan -- the likely loss of an important test of strength in the Republican-controlled Senate.

Yet, while Lefever's withdrawal will allow the administration to cut its losses, it appeared to surprise senior officials of the White House and State Department. The immediate indications last night were that Lefever made his decision in consultation with Hayakawa and other Republican supporters in the Senate and advised the administration only after he had decided to step aside.

Apparent confirmation of that came from a statement issued last night by the State Department. It said the department regretted "that this action has occurred" and added:

"We were unaware of his plans, and we were not asked about them in advance of his decision. The president was unaware of it and was not involved."

The White House reacted only with a terse statement reaffirming Reagan's confidence in Lefever's "integrity and competence." No mention was made of offering Lefever, a former clergyman and scholar specializing in ethical studies, another appointment in the administration.

Senior administration sources said last night that it is a destinct possibility that Reagan will leave unfilled, at least for the forseeable future, the post for which Lefever had been nominated -- assistant secretary of state for human rights.

The president and Secretary of State Alexander M. Haig Jr. have wanted to shift the focus of foreign policy away from the Carter administration's human rights activism. Lefever had been picked for the job because he is an outspoken critic of the Carter approach.

However, his ideas -- particularly the contention that the United States should take a softer line in dealing with friendly rightist dictatorships than with "totalitarian" communist regimes -- provoked strong opposition from human rights organizations and liberal Democrats in Congress.

Liberal and moderate Republicans also had misgivings, as yesterday's action by the Foreign Relations Committee made clear.

Five of the committee's nine Republicans, including Chairman Charles H. Percy (Ill.), joined the eight Democratic members in voting against Lefever. Other Republicans breaking ranks with the administration were Charles McC. Mathias (Md.), Nancy Landon Kassebaum (Kan.), Rudy Boschwitz (Minn.) and Larry Pressler (S.D.).

Percy, expressing their basic position, said "We cannot credibly stand up in the world as the defenders of freedom and democracy if we condone the violation of basic human rights and fail to speak out when violations occur -- wherever they may occur . . . . Dr. Lefever's confirmation would be an unfortunate symbol and signal to the rest of the world."

Administration sources admitted earlier that, as part of White House efforts to twist Senate arms on Lefever's behalf, a hold had been put on Percy's candidate for U.S. attorney in the northern district of Illinois.

In a pointed reference to such pressures and to the bipartisan nature of the vote, Percy said after the committee action:

"I think our country is stronger today because of the vote here. Not only because of the vote itself, but because a majority of members of the majority part decided, despite enormous pressure, to take a stand for human rights. They have served this country's ideals well; and I suggest, in the long term, what they did will have served this administration well, too."

A growing realization that this attitude appears to have considerable support among other Senate Republicans as well as Democrats apparently led to the end of Lefever's campaign to win confirmation.

Senate sources said that, after the committee vote, Hayakawa told other Republican senators that he did not think it would be possible to get the full membership to override the unfavorable recommendation.

That led to a meeting among Hayakawa, Senate Majority Leader Howard H. Baker Jr. (R-Tenn.) and Sen. Jessee Helms (R-N.C.), a leader of the Senate's more ideologically conservative Republicans. According to the sources, Hayakawa, a longtime friend of Lefever, then telephone the nominee and, following a long talk with Lefever and his wife, reported to colleagues that Lefever would withdraw in a statement to be made public by Hayakawa.

News of Lefever's action touched off jubilation among congressional Democrats, who had been noticeably unsuccessful in major legislative skirmishes with Reagan. When word that the Foreign Relations Committee had voted against Lefever reached a meeting of the Democratic National Committee in Denver, it was greeted with a standing ovation.

More restrained were the reactions of Senate Democrats outspokenly against the nomination. Such senators as Claiborne Pell (R.I.), Edward M. Kennedy (Mass.) and Paul Tsongas (Mass.) issued statements calling yesterday's developments a "victory" for human rights, while lauding Lefever as a decent man whom they regarded as the wrong choice for the position.

This buoyant Democratic spirit was precisely what the White House had hoped to prevent when it decided to fight for Lefever despite growing signs his nomination was in deep trouble. As his confirmation hearings produced increasingly emotional controversy, it quickly became clear that the administration was interested less in Lefever's fate than in its own political prestige and clout.

As one senior White House official said yesterday before Lefever withdrew, "We don't want to set any precedents that would make it difficult on other appointments. We don't want to lose one because the Democrats would get a taste of blood."

However, that administration goal eventually was swamped by heavy opposition to Lefever as an alleged hardline anti-communist uninterested in rightist excesses, by his brothers' suggestions -- denied by him -- that he believes blacks are genetically inferior, and by questions about possible conflict of interest in fund-raising activities of the Ethics and Public Policy Center, a private research organization that he leads.

Lefever was attacked especially over the propriety of the center accepting contributions from the Nestle Corp. while distributing information supporting Nestle's highly controversial marketing of infant formula in the Third World.

Last night, after his withdrawal statement was public, Lefever emerged from behind the locked glass doors of his seventh-floor State Department office, tossing the aside, "C'est la vie," to a crowd of reporters outside. Asked what he intended to do now, he replied: "I'm tired. I'm going home to see my wife."

He kissed a woman aide on the cheek, muttered that he probably would be back in the office Monday, then drove off into the gathering twilight.