US President Barack Obama said Wednesday he wants to ensure that efforts for a two-state solution to the Israeli-Palestinian conflict will be kept alive beyond his presidency, as he met Prime Minister Benjamin Netanyahu for likely the last time before he leaves the White House in January.

Speaking in front of the press before their meeting at a hotel in Manhattan, the two leaders broadcast an extremely friendly vibe, sweeping under the rug years of a famously testy relationship.

But along with the smiles, Obama indicated that in their private talks he would push Netanyahu on ways to get back to the negotiating table with the Palestinians and curbing settlement activity in the West Bank.

Senior US officials said the private part of the meeting lasted a little over half an hour and Obama was more pointed, raising “profound US concerns” that settlement-building was eroding prospects for peace.

Netanyahu challenged that notion, said one official, adding that the two leaders had not “papered over” their differences.

But in public, the two were all smiles, only briefly mentioning peace efforts and other divisive issues. The word “Iran,” a country whose nuclear program has been the source of considerable friction between them, was not mentioned once.

The sides need to “keep alive the possibility of a stable, secure Israel, at peace with its neighbors, and a Palestinian homeland that meets the aspirations of their people,” Obama said during brief remarks before the private talks, adding that he would use that meeting to get a sense of Israel’s thinking on the “opportunities and challenges” over the next few years.

Obama added that “our hearts go out to those who’ve been injured — both Israeli and Palestinian,” and said, “Clearly there is great danger of not just terrorism, but also flare-ups of violence.” He then noted: “We do have concerns around settlement activity as well.”

Netanyahu told Obama that Israel “will never give up” on the goal of a durable peace.

Obama said Netanyahu had “always been candid” with the US, likely referencing the long history of spats between Jerusalem and Washington over the past six years, notably over the Iran nuclear deal and Israeli-Palestinian peace efforts.

Netanyahu opened his remarks by thanking Obama for a recent $38 billion defense aid package and talking up the strength of the Israel-US relationship, notably in security and intelligence cooperation.

“I don’t think people understand the length and breadth of this relationship,” he said.

The prime minister stressed the challenges posed in the Middle East by unremitting fanaticism, on the one hand, and the opportunities for peace, on the other.

He said Israel has no better friend than the US, and vice-versa, and thanked the president personally on behalf of the people of Israel for his contribution to ensuring Israel’s security. Obama’s influential voice would resonate for decades after the end of his presidency, Netanyahu said.

He also invited Obama to visit Israel.

“I want you to know, Barack, that you will always be a welcome guest,” Netanyahu said, going on to invite the president to his private residence in Caesarea, where he noted that there is a golf course so that Obama might improve his “terrific” golf game.

“Let’s set up a tee time,” Obama replied. He later said he would visit Israel often after his time in office “because it’s a beautiful country, with beautiful people.” If he brought his wife and daughters, he added lightly, they’d enjoy the fact that, as a private citizen, he wouldn’t have to participate in bilateral negotiations.

US President Barack Obama, right, shakes hands with Israeli Prime Minister Benjamin Netanyahu during a bilateral meeting in New York, September 21, 2016. (AFP/JIM WATSON)

US President Barack Obama, right, shakes hands with Israeli Prime Minister Benjamin Netanyahu during a bilateral meeting in New York, September 21, 2016. (AFP/JIM WATSON)

Obama began his comments by expressing wishes for the speedy recovery of former President Shimon Peres, 93, who suffered a major stroke last week.

He highlighted the shared US and Israeli values, and hailed Israel as a vital US ally. He said his presidency had been guided by the imperative to maintain a strong Israel that is able to defend itself, and that this imperative is essential, too, to America’s national security. The new aid deal, he said, gives Israel the tools to ensure its ongoing capacity to defend itself in an era of regional difficulty, danger and uncertainty.

While he will be president for just a few more months, he said, Netanyahu would be prime minister for longer, and he wanted to use this meeting to understand how Israel sees the future, and to be sure that the path to peace would remain open. “Our hope is that we can continue to be an effective partner with Israel in finding an effective path to peace,” he said.

The two leaders, each flanked by a team of aides and diplomats, were holding the meeting on the sidelines of the United Nations General Assembly, where Netanyahu is slated to speak tomorrow.

Addressing the world body on Tuesday, Obama had declared that “Israel must recognize that it cannot permanently occupy and settle Palestinian land” — a message that the president, say his advisers, will reiterate to Netanyahu.

Wednesday’s pow-wow in midtown Manhattan’s posh Palace Hotel has been touted as likely the last face-to-face summit between the two leaders, capping six years of largely testy ties, during which the two have met an average of twice a year.

Some of their previous encounters were decidedly more frosty than Wednesday’s friendly display of mutual appreciation in front of the cameras, for instance in June 2009, when Obama surprised the Israeli leader with the call for a settlement freeze, or in May 2011 when Netanyahu appeared to lecture the president about Israel’s inability to return the pre-1967 lines.

The last time Obama and Netanyahu met was in November 2015, following the completion of the Iranian nuclear deal — another source of tension in the relationship — the two seemed particularly concerned with broadcasting a return to business-as-usual.

US president Barack Obama addresses the United Nations General Assembly at UN headquarters, September 20, 2016 in New York City. (Drew Angerer/Getty Images/AFP)

US president Barack Obama addresses the United Nations General Assembly at UN headquarters, September 20, 2016 in New York City. (Drew Angerer/Getty Images/AFP)

During that meeting, too, Obama raised the issue of Israel’s policies in the West Bank, but unlike in previous sessions he only did so privately, not during what has proven in multiple instances to be the awkwardly public press appearance either just before or just after their closed-door talks.

Before Wednesday’s Manhattan meeting, Deputy National Security Adviser Ben Rhodes told reporters that he was certain that Obama would raise the issue of “continued settlement activity, the potential viability of a Palestinian state in the face of that settlement activity.”

What Wednesday’s meeting will not include, however, is a new US peace plan.

Rhodes downplayed reports that the Obama administration was actively preparing a last-ditch effort to broker talks between Israel and the Palestinians. He stressed that “in terms of our own plans going forward, we don’t have plans for the president to pursue a new initiative at this point.”

In recent weeks, speculations have circled that the 10-year Memorandum of Understanding would serve as leverage to bring Israel back to the negotiations table. The New York Times reported that Obama was considering making a final push toward an Israeli-Palestinian agreement, offering the prospect that the US president would either start the ball rolling at the UN General Assembly or in November, after the US presidential elections were completed.

But although Obama criticized both Israel and the Palestinians in his annual speech before the world governing body, his Tuesday remarks did not propose any new guidelines for resolving the decades-old conflict.

Still, Rhodes did keep the possibility of action — and thus speculation — open. “I don’t want to suggest that we’ve never discussed different things that the president could do to move the ball forward,” he said. “But we’re not coming to this meeting tomorrow or moving forward in the coming weeks with a plan for the president to take a particular action on this issue.”

On Thursday, Netanyahu will address the United Nations General Assembly, where is expected to call on the civilized world to support Israel in its fight against terrorism. Shortly before the prime minister takes the podium, Palestinian Authority President Mahmoud Abbas and Iranian President Hassan Rouhani will address the forum.

The Associated Press contributed to this report.