His childhood in South Africa was happy until the Soweto riots alerted Donald McRae to apartheid's brutality. He became critical of his father, unaware that he was secretly planning to transform the country

As a small boy, growing up in South Africa in the 1960s, during the bleak years of apartheid, I loved the way my father sang to me. Dad had a terrible voice, but I always hummed along every Saturday morning when we went looking for a black boy. As our car picked up speed, the songs poured out. He especially enjoyed impersonating Louis "Satchmo" Armstrong, as he boomed:

Hello, Dolly

This is Louis, Dolly

You're looking swell, Dolly

I can tell, Dolly

I laughed every time he followed a pause at the end of a line with that punchy catchphrase, "Dolly!"

Dad usually wore a short-sleeved, checked shirt, cream shorts, long socks and shiny brown shoes that had been polished so brilliantly by Maggie, our black servant, that they doubled as mirrors. Meanwhile, up top, his short-back-and-sides were kept in place by a lick of Brylcreem. I wanted to be like Dad. I wore the same checked shirt and shorts, while my hair was also shaped in a neat Brylcreem bop.

At weekends, the black miners tried to find extra work in pretty gardens such as ours, and so we headed out to the coal dumps where they had been waiting since dawn. I thought they were lucky to become garden boys for a day, especially if they caught Dad's eye when he shouted: "Woo-hoo, John!"

Once, as a smiling black boy ran to us, I asked Dad a question: Why were all black boys called John?

"He's not called John," Dad said. "It's just better than calling him 'boy'."

"Hello, master," the miner said.

"You work hard, John?" Dad asked.

John nodded. "Yes, master …"

Dad was a clever man. In 1961, just before I was born, he became the youngest-ever power station manager in South Africa. Dad worked for Eskom – the country's electricity supply commission. He always reminded us that Eskom gave us light and warmth.

There was no electricity in black South Africa, however, because the natives didn't need it. They were happy working for us.

Eventually, Dad became responsible for the generation of all electricity in white South Africa. In my teenage years, when he was so busy that we saw much less of him, Dad's songs were reserved for the dawn chorus. He used to wake me for school by singing another favourite from his repertoire of Satchmo ditties:

When you're smilin'

When you're smilin'

The whole world smiles with you

I missed the way Dad no longer had time to sing Hello, Dolly to me. Life had become serious.

In 1976, when I was 15, we were rocked by the Soweto school riots. Hundreds of people were killed, with thousands more wounded, during clashes between black students and white soldiers. It became impossible to ignore apartheid's brutality and I berated my parents for forcing our servants to drink out of tin mugs and live in the backyard.

In 1983, when I was 21, I decided to work in Soweto as an English teacher. It was one way of staying out of the army a little longer as I also extended my university career with another part-time degree. I would be one of the few white faces among a million black people.

There were six murders a day in Soweto. And so, on my first morning, I was suddenly terrified. As I prepared to drive into Soweto, Dad put out his hand and, switching to Zulu, a language neither of us spoke, said "Hamba kachle" ("Go well" or, here, "Be careful").

I did not admit it then, but my father was a thoughtful man. There were nights in those dark years when the full miracle of electricity became evident to him from the air. Flying back from his remote power stations, he would stare into the African night. As the plane banked towards Johannesburg, the gleaming city rose up to him as if one layer of darkness after another was being peeled from the eyes of a blind man who could finally see.

Dad felt uneasy only when looking towards Soweto. There, smouldering coalfires punctuated the blackness. Eskom still mainly supplied electricity to a white minority.

During my otherwise happy 18 months in Soweto, I became even more judgmental at home. I relished telling Dad that on winter mornings, when much of the township had to rely on coalfires instead of electricity, Soweto belonged to a Dickensian world of hardship and smog. I held my father personally responsible.

Yet I felt stricken when, in August 1984, I flew away for ever. It was the moment we had dreaded, the moment that my father, in a bitter argument, had once said would define our failure as a family. The idea that I would pack up and leave the country seemed like a betrayal of my parents.

I could not bear the thought of them taking me to the airport; instead my sister and her husband drove me. I held my mother, then turned to my father. He pulled me towards him. Dad kissed me on the cheek, something he had not done since I was a small boy. "Hambe kachle", he said.

Three years later, and unknown to me, Dad risked his freedom and his life's work to venture deep into Soweto. One rainy night, with Moses Metsweni, his driver and close confidante, he met secretly with members of Nelson Mandela's African National Congress. Mandela was still imprisoned on Robben Island, the ANC was banned and the state of emergency had come into force two winters before.

Dad was taken to a private township house where, over a candlelit meal cooked on an open fire, he was asked a question: "So, Mr Electricity, why do you come now?"

"There are many reasons," he said. "But my son worked here. He told me what he saw. He thought we were arguing but, in the end, we were simply agreeing. We all have to change."

He told the men that electricity could transform the country. Electricity, even under apartheid, was colourless.

Initially, the black "comrades" were dubious of a white man talking passionately about his dream of bringing power and light to the whole country. But, within an hour, they shared his vision of "electricity for all". That night, a pact was forged between the black underground and the white chief executive. One day, apartheid would end. One day they would all have light and power.

I only began to understand the extent of my father's work when, in London in February 1993, I read a newspaper article that speculated that, following his release, Mandela might ask Ian McRae to be his first minister of energy. Dad was amused because he was no politician, but he was galvanised when telling me of his inspirational private meetings with Mandela.

Dad also told me about Moses, his driver. Their close relationship had been forged in the difficult days after I left the country and just before Moses's eldest son killed himself. The two fathers lamented their loss. Moses's son was dead, after he succumbed to the daily humiliations of black South African life. Ian was luckier. His son was still alive, 6,000 miles away.

A few years ago, when I visited my parents, Moses came to see me. "When are you coming home?" he asked.

I launched into my usual explanation. My work was in London; my wife and children were all English.

"You must bring them here," Moses said bluntly. "You must come home to your parents."

When I said I could not return home, he spoke sternly. "Your father belongs to us. We call him: 'Ubaba wethu futhi engiu baba wongezi iAfrika yonke …'"

Moses paused, as if he wanted me to translate the words for myself. And then, with a smile, as he stretched out his hands to clasp mine, he explained: "He is our father, our father of Africa …"

Moses held my hands fast. "I am proud to call him my friend," he said earnestly. "You must be proud to call him your father …"

• Donald McRae's Under Our Skin: A White Family's Journey Through South Africa's Darkest Years is published by Simon & Schuster. To order a copy for £13 with free p&p, go to guardianbookshop.co.uk or call 0330 333 6846