U.S. Defense Secretary Chuck Hagel said Tuesday that the U.S. and Israel need to ensure that their alliance remains close, as Mideast security challenges grow more complicated.

"This is a difficult and dangerous time," Hagel said before starting a closed-door meeting with Israeli Prime Minister Benjamin Netanyahu. "This is a time when friends and allies must remain close, closer than ever."

In his remarks, Netanyahu thanked the Obama administration for deepening ties over the past four years. He said the U.S. and Israel's shared interests and values are especially challenged by "the arming of terrorist groups by Iran with sophisticated weapons, and equally, Iran's attempt to arm itself with nuclear weapons.

"This is a challenge that Israel cannot accept, and as you and President Obama have repeatedly said, Israel must be able to defend itself, by itself, against any threat," Netanyahu said.

On Monday, Hagel was asked whether he believes it would be advisable for Israel to attack Iran on its own.

"That calculation has to be made by" Israel, he replied after noting, "Israel is a sovereign nation; every sovereign nation has a right to defend itself."

Hagel did not mention a concern that U.S. officials have voiced in the past — namely, that an Israeli strike would run the risk of igniting a wider war that could draw in the United States.

Hagel wrapped up his three-day trip to Israel by visiting an special forces unit that trains military dogs to find hidden explosives and weapons. He mingled with the soldiers and watched a brief demonstration of the dogs' skills.

The Pentagon chief then headed to Jordan to consult with government officials. Later he was to fly to Saudi Arabia.