The arson attack on Saudi Arabia’s embassy in Tehran that prompted Riyadh to cut diplomatic ties with Iran was initially seen as a victory for hardline opponents of President Hassan Rouhani. But analysts say the incident could ultimately backfire on his foes ahead of Iranian parliamentary elections next month, giving the moderate Rouhani ammunition as he confronts conservatives and works to restore his country’s international reputation. Although similar episodes have occurred in the past — Britain’s embassy was stormed in 2011 for example — Rouhani’s response signals a shift against the “rogue elements” he condemned for Saturday’s attack. The violence has undermined the president’s efforts in the Middle East and beyond to bring Iran out of its relative isolation — exemplified by last year’s deal with world powers on its nuclear programme. His government has maintained its criticism of Saudi Arabia’s execution of Shiite cleric Nimr al-Nimr, which sparked the angry protests at the Tehran embassy and Riyadh’s consulate in Mashhad, Iran’s second-largest city. The row has reduced opportunities for Rouhani to engage with Arab states — several Saudi allies also cut or reduced ties — and benefited those who want to stop his efforts at rapprochement.