Mr Johnson said there was a “very high degree of probability” Iran was behind the drone and missile attacks on two oil facilities, which Tehran denies.
But an Iranian foreign ministry spokesman rejected the PM’s comments.
Abbas Mousavi said they amounted to “fruitless efforts against the Islamic Republic of Iran”, and attacked the British government for “selling lethal weapons to Saudi Arabia”.
The US, which also blames Iran for the oil attacks, is sending more troops to Saudi Arabia.
Saudi Arabia has also accused Iran of carrying out the 14 September attacks, in which 18 drones and seven cruise missiles hit an oil field and processing facility.
“I can tell you that the UK is attributing responsibility with a very high degree of probability to Iran for the Aramco attacks.”
Yemen’s Iran-aligned Houthi rebels have claimed responsibility, while Iran itself has denied any involvement. It warned it would retaliate against any attacks after the US announced it was sending troops to Saudi Arabia.
“Clearly if we are asked either by the Saudis or the Americans to have a role then we would consider in what way we could be useful,” Mr Johnson said.
Asked if military action was possible, he said: “We will consider in what way we could be useful if asked and depending on what the exact plan is.”
Sanctions also remained on the table, he said.
A Whitehall source said the Houthi rebels’ claim of responsibility was “implausible” as the “scale, sophistication and range” of the attack was beyond their capabilities.
The prime minister is attending a joint meeting with French President Emmanuel Macron and German Chancellor Angela Merkel at the UN to discuss the attacks, along with Brexit.
Mr Johnson is also due to meet US President Donald Trump, and the two have discussed the need for a “united diplomatic response”.
In his meeting with Mr Rouhani, the prime minister said he would also bring up the case of Nazanin Zaghari-Ratcliffe and other dual British-Iranian nationals held in Tehran.
Mr Johnson came under severe criticism as foreign secretary after appearing to contradict Mrs Zaghari-Ratcliffe, who says she was in Iran visiting family.
She is serving a five-year sentence on spying charges, which she has always denied.