The Senate, rejecting pleas from President Reagan and Salvadoran President Jose Napoleon Duarte, yesterday voted to halt U.S. aid to El Salvador unless that nation protects human rights and promotes economic and political reform.

The 51-to-47 vote defeated an administration-backed amendment by Sens. Jesse Helms (R-N.C.) and Richard G. Lugar (R-Ind.) that would have changed conditions on military and economic aid into goals.

The test was the first in what is expected to be a series between Reagan and Congress about whether conditions should be placed on aid to Argentina, Angola, Pakistan and El Salvador.

The administration opposes such conditions, and the president called Senate Majority Leader Howard H. Baker Jr. (R-Tenn.) to the White House yesterday morning to lobby against them. Duarte also argued against them in meetings with senators and in a letter.

The vote reaffirmed a decision Wednesday as the Senate opened debate on a $5.8 billion foreign aid authorization bill. The bill earmarks $66 million for military support and $48 million in economic and social assistance for El Salvador.

Under the bill, Reagan would be required to certify, twice a year, that the Central American nation's military junta is exercising control over its armed forces and moving to end "indiscriminate torture and murder," to hold free elections, for economic and political reform and a negotiated peace in its bloody civil war.

The House Foreign Affairs Committee has approved similar conditions, and they are expected to be accepted by the House.

Lugar, with administration backing, argued that the conditions would be impossible to meet and would result in an end of all aid to the U.S.-supported junta.

Sen. Christopher J. Dodd (D-Conn.), author of the conditions, countered this, saying, "This is really an insurance policy" to make sure U.S. funds are being used to benefit the people of El Salvador.

"I don't want another Vietnam. This nation doesn't want another Vietnam . . . . We must have a government down there that we can support," declared Sen. Charles H. Percy (R-Ill.), chairman of the Senate Foreign Relations Committee.

Duarte, in a letter read on the floor, said he supported free elections and is working for political and economic reform. However, he said, formal conditions would be "an unacceptable imposition to a government friendly to the United States."

An 11th-hour administration lobbying effort had some effect as six Republicans, including Baker, who had supported conditions in a test vote Tuesday changed their votes.

But a coalition of moderate Republicans, including Percy, and Democrats gave the administration its clearest foreign policy defeat of the year.

Virginia Sens. John W. Warner (R) and Harry F. Byrd Jr. (Ind.) voted against the conditions; Maryland's Paul S. Sarbanes (D) and Charles McC. Mathias Jr. (R) supported them.