Israel's prime minister and defence minister ordered the country's military to prepare for a strike against Iran's nuclear installations two years ago, according to a television documentary.

But the order was not carried out after it met with strong opposition from two key security figures, the military chief of staff and head of the Mossad, claimed Uvda (Fact), broadcast yesterday.

It said that at the end of a meeting of selected ministers and officials Binyamin Netanyahu and Ehud Barak ordered the army to raise its level of preparedness to P Plus, a code signifying imminent military action.

But the army chief, Gabi Ashkenazi and the Mossad head, Meir Dagan, who were at the meeting, opposed the move. According to the hour-long Channel 2 programme, Dagan told Netanyahu and Barak: "You are likely to make an illegal decision to go to war. Only the cabinet is authorised to decide this." The programme reported Dagan saying after the meeting that the prime minister and defence minister were "simply trying to steal a war".

Ashkenazi voiced fears that raising the alert level would "create facts on the ground", making a military strike inevitable. He was quoted as saying: "This is not something you do unless you are certain you want to execute at the end."

Both security chiefs have since left their posts.

Barak, who was interviewed for the programme, said the order was not carried out because the military did not have the necessary operational capability. He rejected the notion that security chiefs vetoed the order.

"The things you are describing are the responsibility of the government," he said. "The idea that if the chief of staff does not recommend something that is possible to do, then we cannot decide to carry it out – this has no basis in fact. The chief of staff must build the operational capacity, he must tell us from a professional point of view whether it is possible to carry out an order, or if it is not possible, and he also can – and must – give his recommendation. [But] it can be carried out against his recommendation."

Barak also said that raising the alert level "did not necessarily mean war".

The reporter for the programme, Ilana Dayan, said Israeli military censors prevented her from disclosing the date in 2010 for the order.

Since leaving office, both former security chiefs have made clear their opposition to premature military action against Iran's nuclear programme. In August, Ashkenazi said "we're still not there", urging more time for sanctions and diplomacy.

Dagan said bombing Iran was "the stupidest idea I've ever heard". He told CBS's 60 Minutes: "An attack on Iran now before exploring all other approaches is not the right way … to do it."

The current senior echelon of Israel's military and intelligence establishment in Israel is also believed to have serious reservations about launching unilateral military action. The US has urged restraint, arguing that sanctions need time to take effect.

In his speech to the United Nations in September, Netanyahu pulled back from the likelihood of an imminent Israeli strike when he declared that a "red line" – the point at which Iran is close to nuclear capability – would not be crossed until next spring or summer. The Iranians say their nuclear programme is for domestic use, not to create weapons.

Scott Johnson, a senior analyst with IHS Jane's, said that Israel still faces the same capability issues as two years ago. "The capability issues that prevent them from performing a unilateral strike are the same now as they were in 2010," he said, citing the lack of air-to-air refuellers and heavy-duty bombs needed to penetrate underground bunkers. "They can plan and prepare for a unilateral strike as much as they want, but they can't actually do it without the US."

The timing of the broadcast, two months before a general election in Israel, could be significant, said Meir Javedanfar, an Iranian-born Israeli analyst. "If Netanyahu and Barak are shown as too eager to go to war without considering opinion inside the cabinet and security establishment, that makes them look reckless. The fact that the [Israeli] military censors allowed the programme to be aired could mean that they are trying to show it was the military establishment that basically saved Israel from possible disaster."

Channel 2's disclosures came as a respected Israeli thinktank, the Institute for National Security Studies (INSS), published the outcome of a war game simulating the 48-hour period after an Israeli strike on Iranian nuclear installations. In the scenario, Israel does not inform the US of its operation until after its launch. Iran reacts by launching around 200 missiles at Israel, and urging its proxies Hezbollah and Hamas to do likewise. However, it is careful to avoid attacking US targets in the immediate aftermath of a strike.

According to the INSS, there are two opposing outcomes of an Israeli attack: "One anticipates the outbreak of world war three, while the other envisions containment and restraint, and presumes that in practice Iran's capabilities to ignite the Middle East are limited." Its war game "developed in the direction of containment and restraint".