It was a silly and unnecessary battle about ego, credit and public relations that ended Thursday morning with a face-saving clarification by the Shin Bet (Israel Security Agency), which practically has to be read as an apology for the IDF and its Military Intelligence branch.

Trying to mend an unprecedented rift with the army and restore close cooperation, the Shin Bet admitted that it did not provide an early warning that Hamas had planned to initiate an all-out war with Israel last summer, which became known as Operation Protective Edge.

The clash began already during the first days of the war, when the head of the Shin Bet, Yoram Cohen, said during a cabinet meeting that his agency had issued a warning of a pending war.

Ministers responded angrily, telling him that they did not recall such a warning.

Actually, the exchange should have served as a warning for Cohen himself and the Shin Bet to restrain themselves in their search for glory and credit. But they didn’t stop there. After the war, the Shin Bet continued its PR campaign by leaking the same claim off the record and briefing journalists who published it.

Despite being furious, the IDF at least publicly swallowed its pride. But this week it could no longer tolerate what it has perceived as systematic and deliberate effort by the Shin Bet not only to grab the credit but also to defame the army.

The trigger that got on the IDF’s nerves, was the prestigious, highly rated Uvda (“Fact”) program on Channel 2, which aired the whole story, not just the facts and information. The program interviewed two very senior Shin Bet officials – one of whom is a candidate to replace Cohen when his term ends in two years.

This was an unprecedented act. Never before had Shin Bet officials on active duty gone public on television, even if their faces were blurred and names not given, as the law requires. No doubt the two appeared on the show with the authorization, blessing and encouragement of Cohen.

Chief of Staff Lt.-Gen. Benny Gantz could no longer remain silent. He exploded, along with the previous chief of Military Intelligence, Maj.-Gen. Aviv Kochavi, and Defense Minister Moshe Ya’alon. The three interpreted the ongoing saga as a direct assault on them for not preparing the army for the war.

Going out of his way, Gantz wrote a letter to his boss, Ya’alon, and to Prime Minister Benjamin Netanyahu, who is responsible for the Shin Bet. The letter, not surprisingly, reached the media. In his letter Gantz complained that the Shin Bet did not provide any warning of Hamas’s plans for a July war.

“Never, not in any meeting headed by me, was the issue of the possible war or [terrorist] operation presented, let alone [any] discussion at the beginning of 2014 on the matter of a coming war,” the letter stated.

For Gantz, the security service had crossed a red line by cooperating with a “television show, which glorified the organization while tarnishing the political echelon.”

This, Gantz concluded, was “a moral and ethical breach.”

Netanyahu called a special meeting on Wednesday night with Ya’alon, Gantz and Cohen. He called Cohen and Gantz to order, reprimanded them and demanded in the name of “national responsibility for security” that they stop quarreling and “continue to fully cooperate for the safety of the citizens of Israel.”

The truth is that, already in January, the Shin Bet had gleaned information mainly from its impressive SIGINT (electronic intelligence) capabilities pointing to the start of “preparations and training by Hamas of a possible conflict with Israel.”

But as the Shin Bet admitted in its statement, “It was only at the end of April that the Shin Bet issued a warning of Hamas’s intentions to conduct a large terrorist attack that could lead to a conflict.”

Most probably Hamas planned to attack via one of its tunnels leading from Gaza to Israel.

It is worth mentioning that, in the field of intelligence, an early warning of a war has a very clear meaning. It has to contain precise information, answering questions as when, where, and how. The Shin Bet information in the months leading to the war didn’t have this.

It goes without saying that, being a terrorist organization and not a regular army, Hamas was not in a position to launch a war against Israel; it could only plot a series of big and even coordinated terrorist or semi-military attacks.

All experts agree that the recent war in Gaza was the result of undesired escalation by both sides, which got out of control. It was not premeditated.

There are two main victims of this battle – the public trust in its security chiefs and Yoram Cohen. Cohen is emerging of the incident battered and less sophisticated than had been thought about him. He is viewed by the prime minister, defense minister and cabinet as a man who cares more about his image than the truth. He is less respected by his subordinates for dragging the agency into an unwanted rift with their peers in the military.