William and Kate visited a government-run school in the capital, Islamabad, which educates young people between the ages of four and 18.
It marked the start of the royal couple’s first full day of engagements after arriving in the Commonwealth country on Monday evening.
Both sat with children in a kindergarten class during the visit to the school, which is for the most disadvantaged young people in the area.
UK aid has helped more than 5.5 million girls get a quality education since 2011, according to the British High Commission.
The duke and duchess also met a group of teenagers, and William was asked what he had wanted to do when he was younger.
Aima, 14, told him she wanted to be a brain surgeon.
The duke replied: “Actually I changed a lot as I got older, but I always wanted to learn to fly.
“I was flying for a while a actually. I love flying, I feel very free (and) I like learning a skill, I enjoy that. I can relate the science of what you do.”
The same student told William that the students were “big fans of your mother”.
The duke said: “Oh, that’s very sweet of you. I was a big fan of my mother too.
“She came here three times. I was very small. This is my first time and it is very nice to be here and meet you all.”
During another classroom discussion with a group of teenage girls, Kate said:
“This part of the visit is really important to us, the issue of girls and education.”
The duke spoke of the UK’s aim of teaching young people about mental health as he was leaving the school.
“In the UK we’re trying to make sure mental health is part of education as well,” the duke told a teacher.
He said students from disadvantaged backgrounds do not have a “stable health platform to build on” and that education in this area is important.
William has frequently spoken out on mental health, including recently lending his voice to a promotional video for Every Mind Matters, an initiative by Public Health England and the NHS.
He and Kate heard how students are benefiting from the Teach For Pakistan programme, a fast-track teacher training scheme modelled on the UK’s successful Teach First.
Area education officer Mohammed Sohailkhan told reporters that the quality of education – particularly for girls – varies across the country.
“In recent years there has been gradual progress in understanding how important education is for girls and young women,” he said.
“There is a realisation of what it can mean in terms of jobs and prospects.
“I can’t paint you an entirely rosy picture. It does still fluctuate wildly, particularly in rural regions, where there has traditionally been cultural barriers towards this, notably in terms of sending girls away to college.
“But these barriers are slowly being broken down.”
Kate opted for a royal blue kurta, a traditional long shift blouse over trousers, for the visit, while William wore a light blue shirt and dark trousers.
Continuing the theme of education, the couple later joined children from three local schools in the Margalla Hills, which sit in the foothills of the Himalayas.
William and Kate are also due to have lunch with Prime Minister Imran Khan and attend a special reception at the National Monument in their first full day of engagements.