She posted a picture of herself in Barkana area on social media platform X along with a message.
"It was such a joy for me to return there today - after 13 long years - to be surrounded by the mountains, dip my hands in the cold river and laugh with my beloved cousins," wrote Yousafzai.
"This place is very dear to my heart and I hope to return again and again," added the activist, who traveled to Barkana, in conflictive province Khyber Pakhtunkhwa's Shangla district, with her father and husband.
According to a local administrator who did not want to be identified, the visit was kept in the strictest secrecy to avoid any adverse situation.
The official added that the area where Yousafzai stayed was closed for several hours to provide the maximum possible security for her and her family.
During her visit, Yousafzai met with relatives and visited the graveyard of her ancestors, as well as a school and a university. Within the framework of her Malala Fund, in 2018 she had created projects to provide free education to girls, according to the administrator.
When Yousafzai was 15 and gaining a public profile as an award-winning young activist for female education, Taliban gunmen boarded her school bus after she had sat an exam in the Swat Valley, asking for her by name, before shooting her in the left side of her head.
The Swat Valley was at the time dominated by the Pakistani branch of the fundamentalists who had imposed a strict regime banning girls from attending schools.
Following the attack, she was evacuated to the UK for medical treatment and has resided there ever since.
Her advocacy for girls' education propelled her to international prominence, culminating in her receiving the Nobel Peace Prize in 2014, aged 17, making her the youngest recipient.
Yousafzai's visit to Khyber Pakhtunkhwa comes after an attack in recent days that killed 34 people - 16 insurgents, 13 civilians and five soldiers - when insurgents stormed a military base in the city of Bannu on Tuesday night.
"I pray for peace in every corner of our beautiful country. The recent attacks, including in Bannu yesterday, are heartbreaking," the activist said in her message.
"I am sending my condolences to the victims and their families and offer my prayers for the safety of every person in my homeland."