Pakistan has strong relations with Saudi Arabia, with more than 2.5m of its nationals living and working in the kingdom
Pakistan Prime Minister Imran Khan visited Iran on Sunday on a mission to act as a "facilitator" between Tehran and Riyadh and try to defuse rising tensions in the Gulf.
Khan landed in Tehran around midday and met with President Hassan Rouhani at the presidential palace.
He was also scheduled to hold talks with Iran's supreme leader Ayatollah Ali Khamenei, before travelling to Riyadh on Tuesday.
"The reason for this trip is that we do not want a conflict between Saudi Arabia and Iran," Khan told reporters as he stood alongside Rouhani.
"Whatever it takes we must never allow this conflict to take place, because we know, Mr. President, that there is a vested interest that wants this to take place," he told Rouhani.
Noting that it was a "complex" issue that can be resolved through talks, Khan warned that any conflict between Iran and Saudi Arabia would "cause poverty in the world".
Pakistan has strong relations with Saudi Arabia, with more than 2.5 million of its nationals living and working in the kingdom, but it also maintains good relations with Iran and represents Tehran's consular interests in the United States.
This is Khan's second visit this year to Iran, which shares a border of about 1,000 kilometres (620 miles) with Pakistan.
Emphasising that the visits to Tehran and Riyadh were Pakistan's "initiative", Khan said he was also approached by US President Donald Trump to "facilitate some sort of dialogue between Iran and the United States".
Tehran and Washington have been at loggerheads since the US withdrew from the 2015 Iran nuclear deal in May last year and reimposed sanctions on the Islamic republic.
Rouhani repeated Iran's official line that the United States must return to the deal and lift sanctions before any talks can take place.
"Any goodwill gesture and good words will be reciprocated with a goodwill gesture and good words," he said.
Rouhani said he had expressed Iran's concern about Gulf security and especially a "missile attack" Friday on an Iranian vessel off the Saudi coast.
"We expressed our concerns to the prime minister about the incidents happening to oil tankers, especially the Iranian oil tanker in the Red Sea on Friday," he said.
Tehran says the Iranian-flagged Sabiti tanker was hit by two separate explosions off the Saudi port of Jeddah, making it the first Iranian vessel targeted since a spate of attacks in the Gulf that Washington has blamed on Tehran.
Rouhani said he had presented Khan with evidence from the incident and that investigations were ongoing.
"If a country thinks that it can cause insecurity in the region and not receive a proper response, it is mistaken," Rouhani said, without elaborating.
There has been a series of still-unexplained attacks on shipping in and around the vital seaway involving Iran and Western powers, as well as drone attacks on Saudi oil installations.
Washington has accused Tehran of attacking the vessels with mines and of being behind the drone assault, something it strongly denies.
Khan met both Rouhani and Trump at the United Nations General Assembly last month, shortly after he visited Crown Prince Mohammed bin Salman in Saudi Arabia.
The Pakistan premier said he was "very encouraged" by talking to Rouhani and will go to Saudi Arabia "in a very positive frame of mind", hoping the two countries can "iron out their differences."