PRETORIA, South Africa — Theophalus Riba got up early Wednesday and hurried to participate in something momentous: He stood in line for five hours under the hot sun to see the casket of Nelson Mandela.

The last time Riba had waited in line that long was in 1994, when he was voting for Mandela as president in the nation's first truly open elections.

Mandela's body lay in state Wednesday at the Union Buildings, once a powerful symbol of South Africa's brutal system of apartheid and the site where he was sworn into office 19 years ago as the country's first black leader.

Laid in a casket made partly of glass to show his face, Mandela, who died last week at 95, was dressed in one of his trademark batik "Madiba shirts," in black and gold. He bore a peaceful, serene expression that greeted those who came to pay homage to the man who negotiated a peaceful end to apartheid and ushered in a stable democracy.

"When I first heard the old man had left us, I was in a terrible state. But now that I've seen his face, I'm very relieved," said Theboho Sephapo, 32, a Defense Department employee. "His face was as beautiful as it was when he was alive.

"The facial expression was at peace," Sephapo said. "It's a sign of a man who's at peace with the world. That made me feel at peace as well."

Some mourners collapsed with grief as they passed the body and had to be helped away. Others wept silently.

Mandla Mandela, the grandson chosen by Mandela to be chief of their clan, stood by the casket. Earlier he had looked stricken as he followed the coffin as it was carried into the complex's stone amphitheater, which President Jacob Zuma on Wednesday formally named for Nelson Mandela.

Most South Africans got their first view of the flag-draped coffin early Wednesday as it left 1 Military Hospital in Pretoria, and for many the reality of the nation's loss seemed to be hitting home.

The mood was somber and deeply sad, in contrast to the joyful celebrations of his life in recent days marking Mandela's contribution as a freedom fighter and peacemaker.

The casket was set under a grand mahogany canopy with a roof of translucent fiberglass tiles, where it was to lie for three days. Zuma entered first to view the body, followed by Mandela's widow, Graca Machel, who placed her hands on the casket and gazed at Mandela before walking on, wiping away tears. Other members of the Mandela family followed.

South African and world leaders then filed past, pausing and bowing in front of the coffin. Former President Thabo Mbeki, who was Mandela's deputy and successor, paid tribute as well.

F.W. de Klerk, the man who with Mandela negotiated the transition from white-minority rule and who shared the Nobel Peace Prize with him, showed visible emotion as he passed. The men received the award almost 20 years ago to the day, on Dec. 10, 1993.

President Obama, who attended Tuesday's memorial service in Johannesburg, was back in the U.S. by Wednesday morning.

The long, snaking lines to view Mandela's body recalled those that black South Africans stood in during the 1994 elections, voting for the first time and overwhelmingly for Mandela. On Wednesday, some carried babies on their hips, some stood stoically in the sun, others flopped exhausted on the grass. By early afternoon, people toward the end of the line wore expressions of defeat.

One woman who had fainted in the heat was treated by paramedics.

Officials said there weren't enough buses to shuttle people from three remote locations to the Union Buildings, leading to long delays. Hundreds waited half a day or more only to be turned away just after 4 p.m. so the body could be returned to the mortuary for the night.

Members of the public were told to walk past the body without pausing, although another Mandela grandson, Ndaba, had requested that they pause and look into the casket.

"I felt a very emotional feeling, seeing this great man, a powerful man, a man who stood up for the country, lying down there," said Charlotte Parker, 24, a member of the ruling African National Congress and a provincial government intern. "I shed tears. I felt hurt, because in my mind I was saying I wish I could have seen him alive, at least shaking his hand, not at his last moment."

Irene Makitla, 33, of Mamelodi township outside Pretoria had gotten up at 5 a.m. to be there.

"I never got the chance to see Mandela when he was alive, so I thought this is a chance to come and pay my respects," she said. "It was so difficult. I felt so emotional. I wished I could just hold his hand."

A government spokesman said that beginning Thursday, visitors would have their fingers dipped in ink to ensure that they didn't get in line again.

"Organizing authorities appeal to people to be patient. Government is trying to accommodate as many people as possible," said Collins Chabane, minister in the president's office. "For this to happen, visitors must comply with the very strict military protocols that govern the lying-in-state. Mourners must set out from home early in the morning and be prepared to wait in line."

Makitla predicted that many people would miss out.

"I know many, many people want to come and see him, and it will be difficult for them. There were so many people waiting."

Mandela's body will be flown to his home village of Qunu on Saturday, with burial to follow Sunday.

robyn.dixon@latimes.com