President Barack Obama has told Palestinians they deserve an “independent and sovereign” state during his visit to the West Bank.

Mr Obama arrived in Ramallah hours after Palestinian militants fired two rockets into southern Israel.

He held talks with Palestinian Authority President Mahmoud Abbas and told a news conference that the US is “deeply committed” to a two-state solution, but the only way to achieve it is through negotiation.

Mr Obama said that Israel’s ongoing settlement building was unhelpful to the pursuit of peace but urged the Palestinians not to make halting the policy a precondition for negotiations.

He said: “We do not consider continued settlement activity to be constructive, to be appropriate, to be something that can advance the cause of peace.”

President Abbas said that peace with Israel should not be achieved through violence, occupation, settlements, arrests or denial or refugee rights.

The rockets fired from Gaza, a reminder of heightened tensions in the region, caused damage to land around a house but there were no injuries.

Police spokesman Micky Rosenfeld said: “One exploded in the back yard of a house in Sderot, causing damage, and the second landed in a field.”

Military officials cited by army radio said they believed the attack was timed deliberately to coincide with Mr Obama’s visit.

Israel pointed the finger for the attacks at Islamist movement Hamas, which controls the Gaza Strip, although there was no direct claim of responsibility.

President Obama – who visited the town where the rockets landed as a presidential candidate in 2008 – was miles away in Jerusalem at the time, preparing to visit the Israel Museum.

There were protesters outside the Palestinian Authority headquarters in Ramallah ahead of his arrival for talks with Palestinian leaders, who have accused him of riding roughshod over their hopes of statehood.

Sky News Middle East Correspondent Sam Kiley said settlements and the controversial “right of return” for Palestinians to their former lands in Israel would be on the agenda.

He added: “The crucial thing is for President Obama to get back into the peace process.”

Code Red sirens wailed in Sderot shortly after the rockets hit at 7am, forcing commuters and schoolchildren to run to bomb shelters.

Yossi Haziza, a Sderot resident in whose courtyard the first rocket exploded, was looking at the walls of his home sprayed with shrapnel and shattered windows.

He said: “I wish this was merely damage to property but my eight-year-old daughter and my wife are terrified. We just want to live in peace. We don’t want to keep having to run to bomb shelters.”

Mr Obama, on the first foreign trip of his second term, says he has come to the Holy Land simply “to listen” to the parties about how to resume peace talks frozen for two-and-a-half years.

He said he decided against coming with a comprehensive peace plan that might not be fit for current political conditions.

The US President’s new approach was in stark contrast to early in his first term, when he declared Israeli settlement building to be illegitimate and promised to dedicate himself to peace.

Meanwhile, Palestinian activists set up a protest camp on West Bank land east of Jerusalem where Israel has announced controversial plans to build, demanding an end to Obama’s “bias and support for Israel”.

Israel’s plan to build thousands of new settler homes in an area called E1 has sparked a major international backlash, with experts saying it could wipe out hopes for a viable Palestinian state.