ISLAMABAD — Iran’s President Hassan Rouhani said Saturday Tehran was not interested in maintaining tensions with Saudi Arabia and responded positively when Pakistan offered to mediate between the two rivals.
Speaking at a news conference in Islamabad to mark the end of his two-day visit to Pakistan, Rouhani said Saudi Arabia plays an important role in the Muslim world and that ‘‘if there is any problem between two countries, it should be resolved through talks.’’
‘‘Iran’s nuclear pact is an example for the world. We have overcome problems through dialogues,’’ he said.
Pakistan is a key ally of Saudi Arabia and shares a long border with Iran.
The trip was Rouhani’s first visit to Pakistan and followed efforts by Saudi Arabia to court Islamabad to increase its participation in a new Saudi-led military alliance of mostly Sunni nations, a coalition perceived by Tehran as an anti-Shi’ite block.
The kingdom has accused Tehran of supporting Shi’ite Houthi rebels in Yemen against the internationally recognized president, Abed Rabbo Mansour Hadi. Saudi Arabia has been leading a coalition of mostly Gulf Arab states in strikes against the Houthis. Despite Saudi pressure, Islamabad last year refused to send troops into Yemen.
Pakistani Prime Minister Nawaz Sharif visited Saudi Arabia and Iran in January to mediate between the two.
In a separate development Saturday, the Iranian government denied any involvement in cyberattacks after the United States charged seven hackers linked to the Iranian government with targeting dozens of banks as well as a small dam outside New York City.
Foreign Ministry spokesman Hossein Jaberi Ansari said Iran has ‘‘never had on its agenda any dangerous measures in cyberspace and does not support such moves.’’
He is quoted by state TV as saying the United States ‘‘is in no position to accuse the citizens of other countries, including Iran, without providing documentary evidence.’’
A Justice Department official said the indictments are part of a strategy to shame foreign governments that support such attacks.
US officials are increasingly investigating cyberattacks with an eye toward building a criminal prosecution and identifying by name the hackers believed responsible — and the foreign nation that may be sponsoring them.

