JOHANNESBURG, South Africa (AP) _ President Nelson Mandela was granted a divorce today, ending a 38-year marriage that survived the darkest days of apartheid but collapsed because of allegations of adultery.

In a nation where Mrs. Mandela has a political following of her own, the breakup of the couple had importance beyond the family.

The judge said Winnie Mandela, who contested her 77-year-old husband's divorce request, failed to counter his most serious accusations: that she had cheated on him, and that, since they separated in 1992, they have had a marriage in name only.

``On evidence which was not challenged and the reliability of which can be accepted with confidence, the plaintiff is entitled to a divorce,'' Judge Frikkie Eloff said.

``Divorce is granted.''

Neither of the Mandelas showed any visible reaction, and they did not look at one another. They left without speaking to the dozens of reporters in the courtroom.

The couple wed in 1958 after Mandela divorced his first wife. The marriage quickly came under strain as Mandela was arrested in 1962 and imprisoned until 1990, when he was freed to negotiate an end to apartheid. He later was awarded the Nobel Peace Prize and elected president.

During his imprisonment, Mrs. Mandela, now 60, became an anti-apartheid leader in her own right, popular with the African National Congress's radical wing. But she lost influence as Mandela pushed the ANC along a moderate course.

Mandela fired her early last year as deputy minister of arts, culture, science and technology after a series of controversies.

The judge's decision came just minutes after Mrs. Mandela fired her lawyer, Ismail Semenya, in court. Eloff said the gesture was nothing more than an attempt to buy time, and ordered Mrs. Mandela to defend herself.

``I do not now know what to do my lord,'' Mrs. Mandela told Eloff. ``I am not the state president. I'm an ordinary person.''

Eloff insisted that Mrs. Mandela sum up, and she offered a plaintive: ``This is no ordinary case.''

A hearing to determine the divorce settlement was scheduled Wednesday. Weekend press reports claimed that Mrs. Mandela would seek about $5 million, which she says is half of Mandela's worth.

In an affidavit supporting his divorce request, Mandela said his earning were ``not of consequence,'' but did not specify a figure. His salary as president is about $142,000 a year. He also has income from a best-selling autobiography, but most of those funds go to charity.

The couple separated two years after Mandela was released from prison in 1990, and Mandela filed for divorce last year. During his first day on the stand Monday, the president said his belief that his wife had been unfaithful to him convinced him that the marriage should end.

For the second day, the contentious divorce trial of the country's first couple drew crowds outside the Johannesburg courthouse. The courtroom was packed with journalists and bodyguards, with no room for members of the public eager to watch the proceedings.

Before his dismissal, Semenya had taken Mandela step by step through the arrests, bannings and financial and personal difficulties Mrs. Mandela suffered during their marriage. Mandela had to acknowledge several times that he was unaware of certain incidents, because he had been in prison for 27 years of the marriage.

``She was subjected to very cruel persecution by the security police of the day,'' Mandela said from the witness stand. But he added: ``There were many women in this country who did that. There were many women in this country who suffered far more than she did.''

After a lunch break, Semenya asked for more time to bring in witnesses who would have supported Mrs. Mandela's arguments that a smear campaign by the former white minority government had contributed to the breakup of her marriage, and that the relationship could be saved through mediation by tribal elders.

Eloff refused the request for a postponement, and criticized Semenya for failing to address Mandela's central arguments: that his wife had cheated on him, and that he was determined to end the marriage.

Mrs. Mandela then called Semenya to the defense table. After a whispered conversation, he announced he had been fired.

After Mandela fired her early last year as deputy minister of arts, culture, science and technology, Mrs. Mandela checked into a private clinic and was described as suffering from diabetes.

She remains a member of parliament and leads the ANC Women's League.