As many as 600 people called the squalid five-story building at 80 Albert Street in downtown Johannesburg home. Nearly three weeks after a fire tore through the building, leaving at least 77 people dead, survivors recall those they lost and the workaday family lives they led inside a trash-strewn building that had no heat, and little water or electricity.

They were South Africans who had made their way to Johannesburg from rural provinces, and migrants from countries like Malawi and Tanzania, all trying to eke out a living in the big city. They labored to pay rent to the illegal building’s slum landlords. They found pleasure in small luxuries, and in one another. At least 12 children were among the dead.

These are some of their stories.

Three-year-old Jamila James rarely set foot outside the building because the streets were not safe, said her uncle, Moris Anamwala. She spent her days in a makeshift day care center on the fourth floor while her mother, Phatuma Anamwala, a migrant from Malawi, sold fruit and vegetables on a Johannesburg sidewalk.

In the evenings, Jamila stayed in the room that her mother shared with another single mother who had two children. The children all played together.

Jamila had dolls, a ball and a blue bicycle with training wheels and a basket — a recent gift from her uncle for her third birthday. But her favorite plaything was her uncle’s mobile phone, he said. He lived down the corridor on the second floor, in a room with four other families, subdivided by sheets.

“She would see me and say, ‘Uncle, your phone,’” Mr. Anamwala said. She couldn’t read, but she knew how to navigate to a car racing game.

Jamila’s mother and uncle had been making plans to send the little girl to Malawi to be raised by a grandmother whom she had never met.

Their village on the southeastern shore of Lake Malawi is poor, but they thought that Jamila would be safer there and could walk to school, play with her cousins and learn to ride her new bicycle.

Days before Jamila was scheduled to leave, the fire broke out. No one in their room survived.

Nokwanda Khanyile, a primary school teacher, had already bought the leather skirt, a Zulu tradition, that would sway when she finally danced at her own wedding.

Ms. Khanyile and her cousin, Buyisile Khanyile, had danced for years at family gatherings, and they were looking forward to celebrating Ms. Khanyile’s nuptials in her hometown, Nkandla, in South Africa’s eastern KwaZulu-Natal province, early next year.

Ms. Khanyile had a postgraduate degree in education, but struggled to find work. She finally found a job at a primary school in Soweto a few months ago, and had planned to move out of the run-down building as soon as she had enough money saved.

Her pay was meager. But she loved her students, her cousin said, and never complained about the packed classrooms in the underfunded public school.

“She was a really open person,” said Buyisile Khanyile.

Her fiancé is also a teacher. The couple have a 2-year-old son, who was living in KwaZulu-Natal while his parents were working, laying the foundation for their future. Now, her fiancé is planning her funeral.

Memory Ngulube would squeal as a coin-operated horse rocked her back and forth in a shopping mall arcade, said her uncle, Tom Nkhwazi Ngulube. On weekends, the little girl and her mother, father and uncle would walk the few blocks to the Carlton Centre mall, in one of Africa’s tallest buildings, where they would split a pizza.

The little girl seemed to take after her mother, who loved the motorcycle racing games in the arcade.

At 2 years old, “she had a nice life,” said Mr. Ngulube.

The dilapidated building was the only home she knew, and these outings were a respite. Her mother, Joyce Banda, had just started selling prepaid mobile phone vouchers on the street, while her father worked as an elevator technician. Other women in the building would watch Memory.

Her mother did not survive. Her father did, but was badly burned.

Memory’s uncle identified his niece’s tiny body by her pajamas and the baby blanket she was still wrapped in.

Memory James was always at her mother’s feet when she cooked. The pudgy 2-year-old would reach for cooking utensils, while her mother, Janet Issa, tried to keep her safe as she prepared food on a gas cooker in a shared room, recalled Memory’s older sister, Peace James.

Ms. James, 19, was just beginning to get to know her baby sister, having moved to Johannesburg from Malawi in June to work as a seamstress.

Memory’s parents could not afford to buy toys for the little girl, but the neighbors who lived in the same cramped quarters would let Memory leaf through their yellowing magazines. Even as a toddler, Memory would gently turn the pages of books, Ms. James said. She was especially excited when she found any pictures with food.

Memory would listen to music on her parents’ mobile phones, and seemed to especially like the gospel hymns saved to her mother’s phone.

Memory and her mother perished in the fire, and her father is missing and presumed dead. Any photos of Memory were lost with them, Ms. James said.

Ms. James, who speaks no English, mustered the few words she knew to softly sing the hymn that her sister would always gurgle along to: “Just give me strength, to do everything I love to do.”

Sixteen-year-old Melita Mhlebi spent the last few months watching clips of Beyoncé’s latest world tour. She mimicked the dips and spins of the choreography, and belted out “Break My Soul,” her favorite song on the “Renaissance” album.

“Beyoncé was her role model, more than me,” said her mother, Busisiwe Mhlebi.

Still, she was more like her mother than she acknowledged. Melita was good at math and science, as is her mother, who had wanted to go to medical school but could not afford it. Melita also inherited her mother’s singing voice.

Her mother had left the rural Eastern Cape Province to chase the dream of becoming a backup singer. But as gigs dried up, the family moved into 80 Albert Street. Melita watched her 36-year-old mother’s health deteriorate, her blood pressure rocketing to dangerous highs.

“She wanted to be Beyoncé, other times she wanted to be a doctor,” her mother recalled.

They argued about Melita’s spending hours at the internet café watching zombie movies and music videos. Her mother scolded her when she came home to the dangerous building after dark, dodging drug dealers and addicts. Mother and daughter fought often, but quickly made up, her mother said.

They wore each other’s clothes, and Melita helped her mother take care of her 2-year-old brother. She had a smart mouth and a quick answer for everything, sass that her mother now desperately misses.

“She was like my sister, we grew up together,” Ms. Mhlebi said.

On the night of the fire, Ms. Mhlebi jumped out their window on the fourth floor and blacked out when she hit the pavement. She thinks her daughter saw her fall, thought she had died and ran back inside.

Imuran William, 17, arrived in South Africa from a fishing village in central Malawi less than a year ago and found a room that he shared with other migrants, sleeping on a mattress in a crowded room. His best friend, Abdul White, came from the same village.

Mr. William’s first job was as a cook in a Nigerian restaurant, thanks to his friend, but life in a sweaty kitchen was not for him. He landed a job in a clothing store in the city center, selling the knockoff designer brands he loved to wear. He spent his money on trendy sneakers and wore his narrow jeans low.

His meager paycheck went to entertaining girls in inner-city pubs and dance halls, but he never touched alcohol, adhering in part to his Muslim upbringing.

Mr. White said he urged his friend to send money back to his family, and focus on building a house in Malawi and a stable life he could return to one day.

“He would say, ‘Me, I’m enjoying my life,’” Mr. White said.

Mr. White said he had no photos of his friend because both of their phones were lost in the fire.

Rokaya Mendru worked seven days a week, trudging up and down Johannesburg’s streets from sunrise to sunset selling mobile phone vouchers.

But Sunday afternoons were sacrosanct, said her younger brother, Michael Limbani, and his wife, Ines Adam. That was when she traded her yellow vendor’s vest for her best threads and sauntered down to the city’s trendy, gentrified corner, Maboneng, to have her picture taken by the street photographers who make a living taking portraits of tourists and local fashionistas.

Ms. Mendru, 35, was neither. She moved to South Africa in 2019, recently divorced and desperate to feed her four children back in Blantyre, the commercial capital of one of Africa’s poorest nations, Malawi. She earned about 9,000 rand ($475) a month, and on a good month, as much as 12,000 rand ($633). But almost all of it went back to Malawi to feed, clothe and educate her children: Banatu, 18; Peter, 14; Ishmail, 10; and Ellen, the only girl, 6.

In Johannesburg, she shared a room with Mr. Limbani and Ms. Adam on the second floor of the building. She cooked for the family and they shared everything. Her rice was perfectly fluffy, and her meat stew tasted like home, Mr. Limbani said. She never quite adjusted to Johannesburg winters, though, wrapping herself in three sweaters and a jacket to stand at intersections as she worked, her brother said.

Sunday afternoons were hers alone. In one photograph, she wears a figure-hugging blue skirt; in another, a royal blue lace dress. In yet another, standing back-to-back with a friend, she wears torn denim jeans. These were all outfits she, as a devout Muslim woman, would not have worn back home in Malawi. Her relatives didn’t quite understand it, but they indulged her, saving her portraits.

Dressing up “would make her look beautiful,” said Ms. Adam, her sister-in-law. “And she liked that.”