Liberal lawmakers have agreed on the terms of identical bills to be introduced in the House and Senate to prohibit U.S. businesses and banks from making new investments in or loans to South Africa.

The economic sanctions are designed to put pressure on the South African government to end its official system of racial segregation, known as apartheid.

The legislation to be introduced today would also prohibit further sales in this country of the gold South African Krugerrand coins and would set out steps South Africa would have to follow to have the sanctions lifted, sources familiar with the bills said yesterday.

Congressional officials said it is too early to tell how the legislation will fare in Congress. A less comprehensive effort to ban new investments passed the House last year but was killed in a conference committee.

However, the legislation this year coincides with a wave of protest in this country against the South African government. The Reagan administration has opposed using economic sanctions against South Africa, committing itself instead to a policy of "constructive engagement" designed to encourage reform by working with the South Africans.

The new legislation, called the Anti-Apartheid Act of 1985, will be sponsored in the Senate by a bipartisan group of liberals that includes Sens. Edward M. Kennedy (D-Mass.), Lowell P. Weicker Jr. (R-Conn.), William Proxmire (D-Wis.) and Paul S. Sarbanes (D-Md.).

The House sponsors are Reps. William H. Gray III (D-Pa.), Howard E. Wolpe (D-Mich.), Stephen J. Solarz (D-N.Y.) and Del. Walter E. Fauntroy (D-D.C.). Several moderate Republicans are expected to sign on the House bill before the legislation is officially released at a news conference today.

However, the House sponsors were unable to win support for their bill from a group of conservative Republicans who in December sent a letter to South African Ambassador Bernardus G. Fourie threatening to support economic sanctions against his government unless it took immediate steps to end apartheid.

The letter, signed by 35 House Republicans, surprised many in Congress because most of the signers are from the party's more conservative wing, which has supported the Reagan administration's policy of "constructive engagement" with South Africa.

In the letter, the Republicans had said that "we are looking for an immediate end to the violence in South Africa accompanied by a demonstrated sense of urgency about ending apartheid." If that did not occur, the letter said, the Republicans would recommend that the United States put in place economic sanctions.

An aide to Rep. Robert S. Walker (R-Pa.), who organized the letter to Fourie, said yesterday that the Republicans had decided not to sponsor the legislation because they are working on a bill that would focus not just on South Africa but on other human rights violators as well, such as the Soviet Union.

However, Gray, who tried to persuade Walker and other conservative Republicans to back his bill, said this week that he thought the Republicans were interested only in scoring public relations points, as they did with the letter to Fourie, and not in passing legislation that the administration might oppose.

Walker and other Republicans intend to introduce a bill that essentially would codify the Sullivan principles, a voluntary fair-employment code for businesses operating in South Africa.

It essentially prohibits segregation in the work place. Walker's bill would enforce those principles for all U.S. businesses that operate in South Africa.