The UK backs Israel’s self-defence but is keen to see as few civilian casualties as possible, James Cleverly has said on a visit to the country.
It comes as the Israeli government continues to retaliate following the attacks by Hamas last weekend.
The foreign secretary was earlier seen dashing into a building as warning sirens started.
His visit is to signal the UK’s “unwavering solidarity” with Israel, a Foreign Office spokesperson said.
Speaking to reporters in Israel, Mr Cleverly said the country had a right to defend itself and also to “try and regain those people who have been kidnapped”.
He added that he had discussed Israel’s work to minimise the risk to non-combatants, saying “we would want to see as few civilian casualties as possible”.
But he warned: “Hamas habitually embeds its military capability, its terrorist capability, within civilian populations.”
The UK and US governments have given firm backing to Israel Prime Minister Benjamin Netanyahu’s administration in the wake of Saturday’s attacks.
There are fears that the conflict, which has claimed at least 1,200 lives in Israel – and more than 1,000 people in Israeli air strikes on Gaza – could escalate further.
Attacks on Gaza continued on Wednesday as Israel targets Hamas. However, concerns have been expressed in the United Nations and elsewhere about the impact on civilians.
The Israeli government has stopped the passage of food, water, fuel and medicine into the territory, with the sole remaining access from Egypt shut down on Tuesday after air strikes near the border crossing.
Defence Secretary Grant Shapps earlier said that while Israel needed to respect international law, the UK would “absolutely defend Israel’s right to do what they need to do now to go after Hamas”.
Support for Israel was echoed by Labour leader Sir Keir Starmer.
More on Israel Gaza war
At least 17 British nationals, including children, are dead or missing, an official UK source told the BBC.
Concerns have also been raised for the safety of British citizens who wish to leave Israel.
Shadow foreign secretary David Lammy said he had asked the Foreign Office for clarity on the help being offered.
In a letter to Mr Cleverly, he said: “While Israeli airspace has not officially been closed, most UK airlines have been forced to cancel their flights for the foreseeable future.
“This is obviously deeply concerning for all those who are desperate to return to loved ones in the UK.
“Several countries… have announced rescue flights to return their nationals who are stranded. Does the UK government have plans to do the same?”
British Airways has now suspended flights to Israel after one of its plane returned to London shortly before arriving in Tel Aviv.
Both Prime Minister Rishi Sunak and Home Secretary Suella Braverman have stressed the need to protect the UK’s Jewish community.
Ms Braverman told police chiefs on Tuesday that waving a Palestinian flag on British streets “may not be legitimate” if it is deemed to be a show of support for acts of terrorism.
Labour’s Sir Keir suggested that flag-waving could be an issue in certain contexts.
He added: “It’s very important that at times like this we don’t conflate peaceful discussion of Palestinian issues with Hamas.”