South Africa's senior white political prisoner, Dennis Goldberg, was released today after serving 21 years of a life sentence for joining with black nationalists in plotting the overthrow of white-minority rule here.

Goldberg, 51, was released on the condition that he leave the country, and he flew to Israel this afternoon to join a daughter, Hillary.

A one-time Communist, Goldberg is the first member of the imprisoned leadership of the underground African National Congress to break ranks and accept a conditional offer of release made by President Pieter W. Botha earlier this month.

The organization's leader, Nelson Mandela, a black who is 66 and has spent one year longer in prison than Goldberg, spurned the offer in a speech read to a cheering audience in the black township of Soweto two weeks ago. Mandela said he would make no promises to the government while it maintained its segregationist system of apartheid because "your freedom and mine cannot be separated."

Sources close to the ANC said tonight that Goldberg's acceptance of the offer would cause consternation in the black underground, which has held him up as an example of white sacrifice for their cause.

This is aggravated by the fact that of the original 12 underground leaders arrested in a police swoop in 1963, five whites are no longer in prison while seven blacks are.

Two of the whites, Arthur Goldreich and Harold Wolpe, made a daring escape from security police before their trial began and eventually reached Israel, where Goldreich still lives.

Another white was discharged before the end of the trial, and a fourth was acquitted. Goldberg was sentenced to life imprisonment along with the black leaders of the movement.

Friends of Goldberg said today that he had agonized over his decision, but they had persuaded him during long discussions in visits to the prison that after 21 years it was pointless to "waste any more of his life," as one put it.

They said a key influence in these discussions had been a member of the Supreme Council for the Rehabilitation of Prisoners in the Israeli kibbutz movement, Herut Lapid, who had flown to South Africa two weeks ago at Hillary Goldberg's request to persuade Goldberg to accept the amnesty offer.

In his conditional offer of release to Mandela and other political prisoners, Botha stipulated only that they should renounce the use of violence -- which the ANC turned to after being banned and driven underground in 1960. However, the semiofficial South African Broadcasting Corp. said the government also made a condition of Goldberg's release that he leave.

Goldberg's wife Elaine lives in Britain with their son David, 27. He received only rare visits from members of his family during his imprisonment.

Four other political prisoners, all black, who have served more than 20 years of life sentences for subversion also have accepted Botha's offer and been released.

These blacks, who have been allowed to stay in South Africa and whose names have not been disclosed, ostensibly to protect them from reprisals, were members of the smaller Pan-Africanist Congress, which has almost faded out of existence since it was banned at the same time as the ANC.

Apartheid is applied as rigorously in South Africa's prisons as in its political and social life, so that Goldberg did not serve his time together with his black companions.