In a stinging defeat for the Reagan administration, the Senate Foreign Relations Committee voted overwhelmingly yesterday to impose economic sanctions on white-ruled South Africa, including an end to all U.S. bank loans to the government there.

Striking a compromise between two sets of Republican proposals, the committee approved, 16 to 1, legislation that also would ban computer sales to South African security services or other agencies involved in enforcing racial segregation and would end nuclear trade and cooperation between the two nations.

In addition, the Sullivan principles, which set forth guidelines for improved living and working conditions for nonwhites in the some 300 U.S. firms operating in South Africa, would become mandatory.

The lone holdout on the committee was Sen. Jesse Helms (R-N.C.), who opposed any action. He failed to show up for the final debate over the markup of the bill and cast his vote by proxy.

The Republican-sponsored bill constitutes the strongest economic sanctions against South Africa ever approved by the committee and appears to stand an excellent chance of passage when it reaches the Senate floor.

The Democratic-controlled House may reach a final vote as early as today on stronger legislation, which would end new loans and investment in South Africa and ban computer sales and the importation of South African krugerrands into the United States.

Yesterday, the House brushed aside, by ratios of more than 2-to-1, several Republican efforts to weaken the measure. The most significant vote occurred on an amendment by Rep. Edwin V.W. Zschau (R.-Calif.) that critics said would have gutted the prohibition on importing the gold coins.

The House approved by voice vote amendments to prohibit any kind of nuclear assistance to South Africa and to encourage President Reagan to solicit cooperation from U.S. allies in implementing the bill's sanctions.

The Senate committee approved a similar amendment seeking allied cooperation.

Despite earlier administration efforts to persuade the Senate Foreign Relations Committee not to approve sanctions, the mood among committee members yesterday seemed to be summed up by Sen. Christopher J. Dodd (D-Conn.), who remarked that after five years of rhetorical denunciations of the horrors of South Africa's apartheid system, "the time has come for action. We must take action."

Essentially, the committee approved a series of amendments calling, among other things, for the immediate imposition of three specific economic sanctions proposed by Sen. William V. Roth Jr. (R-Del.) and Sen. Mitch McConnell (R-Ky.) together with Dodd.

The strengthening amendments were attached to a bill sponsored by committee Chairman Sen. Richard G. Lugar (R-Ind.), Sen. Charles McC. Mathias Jr. (R-Md.) and Senate Majority Leader Robert J. Dole (R-Kan.).

The thrust of the Lugar-Mathias-Dole bill is to increase U.S. assistance to the black population of South Africa, including a jump from $4 million to $15 million for scholarships to local schools and universities.

As approved, the bill declares that it is U.S. policy to impose additional economic and political sanctions against the South African government but postpones any decision for 18 months and allows the president to avoid action if he determines "significant progress" has been made by South Africa toward ending apartheid.

The Sullivan principles are named for the Rev. Leon Sullivan. Companies found in violation of them would be deprived of U.S. government aid for their export-marketing activities there.

Lugar made one attempt to help the administration by introducing a substitute it proposed at one point for the amendment banning licenses for the export of any U.S. nuclear goods or technology to South Africa.

The substitute contained a number of loopholes plus a presidential waiver if the president determined the ban would jeopardize U.S. defenses or security or the achievement of its nonproliferation objectives.

The substitute showed no sign of gaining support from Republicans or Democrats. Lugar withdrew it without making much of an attempt to defend it.