Thirty years ago the state of Israel, a refuge from discrimination and persecution for millions of Jews, was born. In the same year the National Party, whose ideology of separate development is based on discrimination by race, came to power in South Africa.

Despite their difference and the vast stretch of Africa continent lying between them, the two countries have gravitated into a close friendship propelled by mutual needs and by fear of annihilation from hostile forces.

"The greater the geographic distance, the better the relations, normally," observed Israeli Finance Minister Simcha Ehrlic on Sunday, as he left Suouth Africa after an eight-day visit that further ties between the two countries.

Coming as international criticism of Pretoria's racial is at a peak. This first visit by an Israeli Cabinet minister emphasizes that Israel is not a fair-whether friend to South Africa.

Israel has appreciated South Africa's loyally in the past."South Africa has never wavered in her attitude toward Israel," said the Israel anbassador to South Africa, Yitzak Unna, "unlike some people when they get a whiff of oil."

As apartheid" and "Zionism" were coupled over the years as target of more and more U.N. resolutions, it was natural that Israel and South Africa came to feel a special tie. There are also similarities between the Afrikaner community that dominates the ruling National Party and the Jewish community that dominates Israel.

"They are both nationalists and both feel they have a religious calling," said one South African. The Afrikaner's original rationale for his ideology of separate development of the races was steeped in the Calvinist theology of his Dutch Reformed Church.

"Both countries are pro-West and anti-Communist," and one South African Jew. Bending geography a bit to make a point, he said, "One is at the northernmost tip of the African continent and the other the southern most tip. They are the most highly develpoed countries on the continent. And what od you have in between? Backward underdeveloped, pro-communist states."

Their anti-communism, however, has not prevented them from pragmatically maintaining relations with nearby Marxist states. South Africa has close economic ties with thew Marxist government of Samora Machel in Mozambique and Israel has shipped arm to the revolutionary government in Ethiopia.

There has been some embarrasment among American Jews about Israel's warm relations with South Africa, a country that is internationally criticized for its repressive police and its racial policies.

To this, Israel officials counter that their relationship does not imply approval of South Africa's internal policies, They point out that unlike many countries that trade under the table with South Africa and then criticize it internationally. Israel's ties are open and above board.

"My visit has been done in a conspiratorial manner." Ehrlich said, "and this is indicative of our relations."

Ehrlich's visit had special meaning for the 118,000 South African Jews who make up less than 3 percent of the 4.5 million whites here and who are among the most affluent and well educated.

Aware of their minority status, South Africans Jews have been cautious as a group about criticizing the racial policies of the government. Individually, however, they have historically been at the frorefront of liberalizing moves here. It is in the predominantly Jewish communities that the progressive Reform Party, which is the National Party's official (though largely ineffective) parlamentary opposton, has its strength. It is barked financially by Jewish diamond magnate Harry Oppenheimer.

Closer between South Africa and Israel are regarded as a protection of Jewish minority, which is sentive to a strain of anti-Semitism in the ruling Afrikaner community, many of whose leaders were pro-Nazi during World War II. The National Party once had a clause prohibiling Jews from membership.

Israel has a special responsibility to the jewish community of South Africa," Unna said. "Their well-being is profoundly affected by relations between South Africa and Israel."As the friendship between the countries warmed, there are has bee a visible change in the Afrikaner attitude toward the Jewish community. Public anti-Sejitic remarks are now taboo and alst November, for the first time, the National Party ran a Jewish candidate for parliament, but he was not elected.

The South African government also has relaxed its currency controls to allow the Jewish Community to send sizable donations to private Israeli foundations. South Africa prohibited these remittances between 1961 and 1967 when it was angered by Israel's support for the liberation movements in black Africa, according to Julius Weinstein chairman of the South African Zionist Federation.

After the 1967 Middle East war, however, when most of black Africa broke relations with Israel, its relationship with South Africa blossomed anew.

The currency agreement was then renewed on the condition that the amount sent would not be publicized. Estimates of the annual remittances have gone a s high as $20 million. "Percapita, the South African Jew gives the higest amount in the world, much more than the American Jewish population," Weinstein said.

Jewish-Afrikaner relations were damaged during last year's election campaign when a newspaper printed a remark by Justice Minister Jimmy Kruger complaining about Jews "sending money to Israel," among other things.

"Many people were upset about the remarks." Weinstein said. "But we made our feelings know to the government and to Kruger and that's the end of the matter." Kruger apologized at the beginning of the parliamentary session.

This improvement in Israeli-South African relations has not offset amny Jews fears about South Africa's uncertain future. Israel is the fourth choice (after Britain, West Germany and Australia) for emigrants leaving this racially troubled country. During 1976 and 1977, an estimated 2,200 people left South Africa to live in Israel, most of them in 1977, according to the Israeli consulate in Johannesburg.

During his visit, Ehrlich encouraged South African Jewish businessmen to invest in Israel. He invited Finance Minister Owen Horwood to Israel and negotiated a $46 million credit line for Israeli purchases of South African industrial products.

He denied that Israel intended to act as a "channel for South African or for any other exports into Europe." He said Israel wanted South African investment to enhance its own productive capacity in order to lessen Israel's dependence on foreign manufactured goods. Ehrlich said he had made similar appeals to Amerian investors.

While economic cooperation between Pretoria and Jerusalem is given high visibility, military cooperation is under a heavy veil.

"There has been tremendous exaggeration of the alleged Israeli-South African military cooperation," Unna said, but many observes feel the cooperation is extensive.

Israel, for example, has sold and delivered South Africa three 420-ton Reshef gunboats, according to Israeli sources. It is understood that at least three more are being built in South Africa under a licensing agreement.

Although the U.N. arms embargo against the South Africa called on all countries to "review" existing licenses with South Africa "with a view to terminating them," Israeli Foreign Minister Moshe Dayan has said that Israel will honor its commitment with South Africa.