The Senate, defying veto threats from President Reagan, voted 58 to 38 to approve a Democratic-sponsored move to restrict testing of the administration's space-based Strategic Defense Initiative (SDI).

It was the Senate's boldest challenge thus far to Reagan on arms control policy, with eight Republicans joining nearly all Democrats in opposing the president's position just as he was wrapping up the final details on an intermediate nuclear force (INF) agreement with the Soviet Union.

Soviet Foreign Minister Eduard Shevardnadze, who has been here all week, met with Reagan Tuesday and again yesterday.

Democrats fell short of the two-thirds vote they would need to override the veto that Reagan has promised if Congress gives final approval to the proposal as part of a defense authorization bill for next fiscal year.

Democrats conceded that Reagan could probably sustain the veto but warned that he faces more trouble, including complications for future arms agreements and the possibility of deep new cutbacks in proposed spending for SDI research, if he persists in maintaining his position.

The administration is "shooting itself in both feet," warned Senate Armed Services Committee Chairman Sam Nunn (D-Ga.), who led the fight for the testing constraints and threatened SDI spending cuts and treaty complications unless the administration relents.

The House last May approved similar testing curbs as part of its defense bill, along with several other arms restrictions that are expected to come before the Senate as it continues consideration of its $303 billion defense measure for fiscal 1988.

The Senate's SDI proposal, drafted by the conservative Nunn and more liberal Carl Levin (D-Mich.), would require congressional approval before the administration could conduct SDI tests based on its reinterpretation of the 1972 Antiballistic Missile (ABM) Treaty.

Administration supporters in the Senate mounted a four-month filibuster to block the defense bill as long as it included the testing curbs, contending that Democrats were impeding progress on SDI by insisting on the original interpretation of the ABM treaty that could prohibit critical tests.

But Democrats held firm, contending that the White House was treading on the Senate's constitutional turf by attempting to reinterpret the treaty without congressional approval in order to allow tests that would be barred under the traditional reading of the ABM pact that was accepted by the Nixon, Ford and Carter administrations.

When the Democrats last week picked up the 60 votes necessary to invoke cloture and shut off debate, the GOP abandoned its filibuster and allowed a vote, timing it to coincide with the U.S.-Soviet talks and using the argument that the Democrats were handing the Soviets a victory at the bargaining table that they could not win on their own.

"What a slap in the face of our negotiators! . . . . We ought to be ashamed of ourselves," Sen. Dan Quayle (R-Ind.) said yesterday in winding up the GOP's case against the proposal.

But the argument against undercutting the president during negotiations, which was persuasive in forcing the Democrats to back off during earlier showdowns -- including one last year on the eve of the Gorbachev-Reagan summit in Iceland -- did not appear to work this time.

Four senators were absent from yesterday's vote. They had previously signaled support for the proposal, meaning it had a potential of 62 votes. The only Democrat to vote against it was Ernest F. Hollings (S.C.). Republicans who supported it were John H. Chafee (R.I.), William S. Cohen (Maine), Daniel J. Evans (Wash.), Mark O. Hatfield (Ore.), John Heinz (Pa.), Nancy Landon Kassebaum (Kan.), Bob Packwood (Ore.) and Lowell P. Weicker Jr. (Conn.).

One reason for the big vote, Nunn and others suggested, was that the administration was encroaching on what the Senate jealously regards as its role in treaty-making and threatening its oft-used "power-of-the-purse" to deny funding for foreign policies it opposes.

Republicans argued that only the president has the power to interpret treaties and said it would be unprecedented for the Senate to write an interpretation into law. Nunn countered that Republicans took a different position when President Jimmy Carter abrogated a treaty with Taiwan and argued that ratified treaties are law that can be changed only by Congress.

If Reagan prevails in a veto showdown, Nunn said, he would support "substantially less" for SDI spending next year than the $4.5 billion that his committee has approved. Reagan requested $5.7 billion, and the House has authorized $3.1 billion.

Moreover, Nunn reiterated his warning that, if the administration continues to claim the ABM negotiating record justifies a broad interpretation, the Senate will have to insist on seeing the full negotiating record for all treaties, including INF, and pass reservations to assure that its interpretation prevails.

With "every scrap of paper" from the negotiating table subjected to public disclosure in Senate debate, Nunn said, a foreign country would "think a long time" before negotiating a treaty with the United States.

In other action on SDI, the Senate approved amendments aimed at keeping the administration from trying to "purchase allied support {for SDI} with research contracts funded by the American taxpayers," as Sen. John H. Glenn (D-Ohio) put it.

As finally approved, 61 to 32, the restrictions would allow contracting abroad for SDI research only if foreign governments pay a "substantial" share of the cost.