President Obama announced Monday that Secretary of State John Kerry is traveling to the Middle East to urge both parties to accept a cease-fire based on the guidelines agreed upon in November 2012. (Associated Press)

The Obama administration took a direct role Monday in trying to end nearly two weeks of fighting between Israel and Hamas, dispatching Secretary of State John F. Kerry to help revive a stalled Egyptian cease-fire effort and increase pressure on ally Israel to limit escalating civilian casualties.

Kerry will hold talks over at least two days in the Egyptian capital, including with President Abdel Fatah al-Sissi, and may travel to Israel later in the week. Aides cautioned that a cease-fire could take several days to negotiate but expressed guarded optimism that, with casualties rising and the Hamas leadership weakened, the timing is right.

“Our goal is to achieve a cessation of hostilities as soon as possible,” said a senior State Department official traveling with Kerry. “The Egyptians are playing the leading role in this effort, but we are willing to engage with anybody who we think can help us achieve that. We don’t expect it will be easy.”

Kerry’s visit comes a day after he was caught on tape apparently criticizing Israel’s offensive in the Gaza Strip as being far larger than the “pinpoint” operation that Prime Minister Benjamin Netanyahu had promised. More than 500 Palestinians have been killed, while Israel has lost 25 soldiers and two civilians.

“We have serious concerns about the rising number of Palestinian civilian deaths and the loss of Israeli lives, and that is why it now has to be our focus and the focus of the international community to bring about a cease-fire,” President Obama said Monday in Washington.

Speaking to reporters on the South Lawn of the White House, Obama reaffirmed his administration’s support for Israel’s effort to thwart rocket attacks by Hamas militants. But he cautioned that “we don’t want to see any more civilians killed” and called for Israel and Hamas to return to the terms of a 2012 cease-fire agreement.

U.S. officials acknowledged that the circumstances are more complicated now. In perhaps the biggest shift, Egypt has returned to a military-backed government after the ouster of President Mohamed Morsi last year. Morsi’s Muslim Brotherhood-backed government had close ties to Hamas, which has held full control of Gaza since 2007, and he was credited with being a key broker in 2012.

The new Egyptian government is firmly opposed to the Palestinian militant group, but U.S. officials note that Egypt holds leverage because it controls crucial border crossings with Gaza.

An Egyptian official said in an interview that Egypt can still speak directly with Hamas and has attempted to draw the militants back to the table.

Hamas wants to negotiate the terms of a truce before it agrees to stop firing rockets into Israel, the official said, while Egypt and other intermediaries are pushing for an immediate halt to the fighting before the detailed talks.

“There is a problem of the egg and the hen” and which comes first, said the official, speaking on the condition of anonymity to describe the confidential government talks.

Hamas spurned the Egyptian truce offer last week, saying it met none of the group’s conditions, but the United States considers it a live proposal. Kerry is expected to urge some changes that might encourage Hamas to talk.

Serious questions remain about whether Hamas now considers a cease-fire to be in its interests, or whether Israel has accomplished enough of its military aims to quit the fight.

Nor is it clear that any outside country or adviser holds enough sway with Hamas to bring it to the table. The United States has no diplomatic dealings with Hamas, which it considers a terrorist group.

The United States can act as a go-between and mediator among Arab states and Turkey, which may be able to exert influence on Hamas and Israel, “at a time of some fractiousness” and competing agendas across the Middle East, another U.S. official said. Three U.S. officials traveling with Kerry briefed reporters on the condition of anonymity to describe the aims of the closed-door diplomacy.

Hamas reiterated Monday that it would not stop fighting until several demands were met, including an end to an economic blockade imposed on Gaza by Israel and Egypt.

“The world must understand that Gaza has decided to end the blockade by its blood and its heroism,” Ismail Haniyeh, Hamas’s deputy leader, said Monday in a televised address.

Kerry met with U.N. Secretary General Ban Ki-moon, who is in the midst of a shuttle diplomacy mission that is expected to take him to Jerusalem on Tuesday. Ban has been critical of the Israeli air and ground offensive in Gaza, calling the violence “atrocious” and saying Sunday that Israel must do more to protect Palestinian civilians.

Kerry said the United States is committing $47 million in humanitarian aid for Gaza.

“We’re deeply concerned about the consequences of Israel’s appropriate and legitimate effort to defend itself,” he said as the Ban meeting began.

“In any kind of conflict, there is a concern about civilians — about children, women, communities that are caught in it. And we’re particularly trying to focus on a way to respond to their very significant needs.”

David Nakamura in Washington contributed to this report.