Nawaz Sharif arrived with a powerful delegation including army chief General Raheel Sharif and Defence Minister Khawaja Asif, who met King Salman and other top government officials.
"The main focus was for solidarity with Saudi Arabia" in line with earlier commitments from Islamabad to defend the kingdom's territorial integrity, the official told AFP.
A Saudi-led coalition conducted a 27-day campaign of air strikes in Yemen aimed at halting the advance of Iran-backed Shiite Huthi rebels and their allies.
Nuclear-armed Pakistan has remained ostensibly neutral in the conflict.
Also Read
The Huthis, allied with army units loyal to former president Ali Abdullah Saleh, are fighting forces on the side of coalition-backed President Abedrabbo Mansour Hadi, whose government has sought refuge in Riyadh.
Pakistan's parliament this month unanimously voted against complying with Sunni-dominated Saudi Arabia's request for troops, warplanes and ships.
Parliament said Pakistan should instead play a mediating role.
In a unanimous resolution it backed the government's commitment to protect Saudi territory, which was not directly threatened during the conflict although there were armed skirmishes along the border.
"The two countries have the type of relations which are pretty mature. They understand what parliament's position was," he said, asking for anonymity.
Saudi Arabia's official press agency only said talks covered bilateral, regional and other issues.
Pakistan has deep military ties with Saudi Arabia and has long benefited from the oil-rich kingdom's largesse.
But it has been reluctant to become ensnared in a conflict with sectarian overtones while violence against minority Shiites rises at home.
Shiites comprise about 20 per cent of Pakistan's population.