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 regional powers.
Rouhani also said his country was ready to help Pakistan overcome its energy problems.
‘‘Iran has constructed a gas pipeline up to the Pakistani border, and now we are ready to provide gas to Pakistan,’’ he said, adding that he hoped Pakistan would complete the pipeline on its side. Work on the Pakistan-Iran pipeline has been stalled for years because of sanctions on Iran, which invested over $2 billion in the project.
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 announced Thursday are part of a strategy to shame foreign governments that support such attacks.
Where punishing cyberattacks were once investigated mostly for intelligence purposes, US officials are increasingly investigating them 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.
‘‘We need to show that these are not anonymous, that there’s no free pass because you do it behind a keyboard in a country far away,’’ said Assistant Attorney General John Carlin, the head of the department’s national security division.
US officials say the strategy known colloquially as ‘‘name and shame,’’ in place since 2012, also is demonstrated in indictments two years ago linking Chinese military hackers to economic espionage of American corporations and in the public blaming of North Korea for a cyberattack against Sony Pictures Entertainment.
The goal, Carlin said, is to have a new ‘‘sheriff’’ patrolling a cyberspace that he says has long resembled the Wild West, where foreign hackers have acted with impunity.
‘‘If you let someone walk across your lawn long enough and don’t tell them to stop, they get the right to walk across your lawn,’’ he said.