P.W. Botha, 90, the unapologetic leader of apartheid-era South Africa who led his country into deepening political crisis and racial violence as head of state from 1978 to 1989, died Oct. 31 at his home in Wilderness, a southern coastal town. No cause of death was reported.

"Peevee" Botha was the bald, bespectacled mandarin of the ultra-right Nationalist Party. His trademark was a finger-wagging belligerence that earned him the nickname the "Groot Krokodil," or great crocodile, in Afrikaans, the Dutch language that was his native tongue.

He held a variety of portfolios before becoming defense minister in 1966. During the next decade, he engineered massive increases in the military budget to minimize the effects of the international arms embargo against the apartheid government.

He also saw the militarization of his country as a way to safeguard South Africa from foreign invasion and internal subversion. To international derision, he undertook incursions into Angola and South West Africa (later renamed Namibia) to end leftist guerrilla uprisings and what he called the "forces of chaos, communism and socialism."

As prime minister and then state president, he veered wildly between upholding and reforming apartheid, the system of racial segregation that his party initiated after coming to power in 1948. He understood its inevitable decline amid uncontrollable protests but was unwilling to appear weak to his followers.

Years after he left office and a new, black-led leadership emerged, Mr. Botha remained defiant during investigations into his regime's hard-line racial policies that led to killings, tortures and disappearances. On a technicality, he successfully evaded testifying before South Africa's Truth and Reconciliation Commission, formed to probe apartheid-era crimes.

"I did not authorize murders," he said to reporters at the time. "I will not ask forgiveness for fighting the Marxist revolutionary onslaught."

Pieter Willem Botha was born Jan. 12, 1916, at his family's farm in the Paul Roux district of the Orange Free State. The area was deeply conservative and populated largely by Afrikaners, the white descendants of 17th-century settlers who were mostly Dutch.

In his teens, Mr. Botha became a member of the National Party, then a minority political group. During the Depression, he abandoned his law school studies at the University of the Orange Free State and began his mentorship under the Nationalist leader D.F. Malan. Mr. Botha was a political organizer, a job that sometimes required thuggery and other forms of intimidation.

During World War II, he helped form the Cape branch of the Ossewabrandwag, or Ox-Wagon Fire Guard, a pro-Nazi paramilitary group that opposed his country's support for the British and other Allied powers. His involvement ended when he was threatened with internment.

In 1948, his party won the general election in a surge of Afrikaner nationalism, and Mr. Botha was elected to the lower house of Parliament.

During his first decade in office, he became his party's chief secretary. Under prime minister H.F. Verwoerd, he was minister of colored affairs; minister of community development and housing; and minister of public works.

In this period, he sometimes fought against the most outrageously racist voices in his party on social and land issues. As defense minister, he championed a liberalization of the military that brought women and those of mixed race into fighting units.

Elected prime minister in 1978, he advocated a program of "adapt or die" that surprised many white South Africans for its reformist ring. This approach was partly because of the moderating influences of a strong political challenger during the election. However, to many blacks, Mr. Botha's efforts appeared cosmetic, and many in his white base charged him with surrendering needlessly.

Radical elements within his party abandoned him in 1982 to form another political party. Soon after, Mr. Botha helped craft a new national constitution that bestowed greater authority to himself by changing his title to state president. During the next few years, he repealed some restrictive laws, including a ban on interracial marriage and a passport system that prevented blacks from living freely away from their designated townships.

He allowed participation by Asians and those of mixed race in Parliament and the national cabinet, but blacks were still excluded from government. A goodwill tour of Europe in 1984 had little effect of changing the country's pariah status, although some Western governments and businesses maintained economic ties. He also eased his diplomatic relations with neighboring countries, nearly all of which were under black rule after having gained independence years earlier.

As rioting continued, he declared a state of emergency in 1986, curbing press freedoms and arresting black political leaders.

After a stroke in 1989, Mr. Botha resisted calls within his own party to resign. "I am not a sulking old man," he said.

In a matter of months, he arranged a meeting at his official Cape Town home with Nelson Mandela, a leader with the banned African National Congress who was serving a long prison sentence.

Mandela later wrote in a memoir that Mr. Botha broke all expectations of the "old-fashioned, stiff-necked, stubborn Afrikaner who did not so much discuss matters with black leaders as dictate to them." He said the president was amicable and smiling and "completely disarmed me," although he declined to agree to the unconditional release of Mandela and other political prisoners.

Within months, Mr. Botha resigned from the presidency and his party. Mandela was released from prison in 1990 and worked with Mr. Botha's successor, F.W. de Klerk, to hold fair elections. In 1994, Mandela became the first black president of South Africa.

During the new era, Mr. Botha was not allowed to retire quietly. Anglican Archbishop and Nobel laureate Desmond Tutu, who headed the Truth and Reconciliation Commission, personally asked Mr. Botha to testify about allegations of bombing campaigns against black rights groups during his presidency.

Mr. Botha declined to recognize the commission's authority to compel him to testify. Instead, he gave the commission 1,700 pages of answers to their questions.

This led to a court's finding him guilty of contempt and sentencing him to either a year in jail or a fine of $1,600. He avoided the penalty when a higher court said the commission's legal mandate to exist was due to expire before he was called to testify.

At the time, Mr. Botha told reporters he was more worried about the lawlessness he saw around him under the new government. "I'm still concerned about the onslaught," he said. "What I prophesied came true."

He wrote an autobiography, "Voice in the Wilderness."

His first wife, Elize Rossouw, whom he married in 1943, died in 1997. The next year, he married Barbara Robertson, a legal secretary 25 years his junior. She survives him, along with five children from his first marriage.