It was not immediately clear what caused the accident late on Sunday near Abbottabad, about 200km northeast of Peshawar.
Authorities transported the bodies and injured to an Abbottabad hospital, said police official Shaukat Khan.
He said the pilgrims were returning from the hill resort of Murree near the capital, Islamabad, after attending a celebration honouring a Muslim saint.
Doctors at Ayub Medical Hospital in Abbottabad confirmed the deaths of 38 people: 23 men, 10 women and five children. All the dead and injured were from the mountainous region of Mansehra, about 150km northeast of Peshawar.
Fatal road accidents are common in Pakistan, where traffic rules are frequently disregarded and public transport drivers often work long hours.