President Biden cautioned Israel Wednesday not to make the same mistakes the United States made after the 9/11 terrorist attacks as Israeli forces are expected to prepare a ground offensive in response to terrorist attacks launched by Hamas.

Biden delivered remarks in Tel Aviv at the end of a trip to Israel meant to underscore his unwavering support for the Jewish state in the aftermath of the Hamas attacks, which killed more than 1,000 Israelis and has set off concerns about a wider conflict in the region.

“Since this terrorist attack took place, we’ve seen it described as Israel’s 9/11. But for a nation the size of Israel, it was like 15 9/11s,” Biden said. “The scale may be different, but I’m sure those horrors have tapped into some kind of primal feeling in Israel just like it did in the United States. Shock, pain, rage. An all-consuming rage.”

“You can’t look at what has happened here … and not scream out for justice,” Biden continued. “Justice must be done. But I caution this: While you feel that rage, don’t be consumed by it. After 9/11 we were enraged in the United States. While we sought justice and got justice, we also made mistakes.”

Biden said the choices in a time of war are never clear and must be weighed against potential costs before noting that the Palestinian people are suffering, and that the vast majority of them are not represented by Hamas.

Following the Sept. 11, 2001, attacks, the U.S. embarked on wars in Afghanistan to hunt down those responsible and then months later, began a war in Iraq. The dual conflicts cost the United States thousands of U.S. troops and spanned 20 years. Biden served as vice president while both wars were being waged and his administration later oversaw the chaotic exit of U.S. troops from Afghanistan in 2021.

The president’s comments came as scores of Palestinians have been killed in retaliatory Israeli strikes on Gaza, which is controlled by Hamas. Israel is preparing an offensive against Hamas, including a potential ground invasion.

World leaders have also sounded the alarm about a humanitarian crisis in Gaza, where civilians have struggled to access food, water and medicine.

Protests have broken out in the Middle East after a hospital explosion Tuesday in Gaza that killed hundreds of people, including patients who were seeking treatment and refuge amid heavy aerial bombardment by Israel over the last week.

While Hamas and some Arab nations have blamed Israel for the explosion, Biden and the White House have said available information indicates Israel was not responsible for the blast.