President Barack Obama defended his record on Israel in a wide-ranging interview on Israeli TV, and said that Israeli Prime Minister Benjamin Netanyahu, with whom he has clashed, “had a good friend” in the White House.

Speaking with Channel 2’s Ilana Dayan in an interview aired Tuesday, Obama defended the Iran nuclear agreement, his push for peace talks and the recent U.S. abstention on a U.N. Security Council resolution criticizing Israeli settlements.

Obama flatly denied Israeli assertions that the U.S. was behind the resolution’s passage on Dec. 23, noting that the U.S. neither wrote the resolution nor introduced it or voted in favor of it. Obama said the U.S. would have vetoed anything that didn’t contain a “balanced statement” condemning what it sees as Israeli and Palestinian missteps, and said the resolution was the “best move” for peace.

“I did believe it was important to send a signal and to lift up the facts that so often get buried under other news in terms of what is happening with settlements in the West Bank,” he said. “I have an obligation to do what I think is right.”

As he has in the past when faced with criticism on Israel, Obama said he has Israel’s best interest in mind and has always ensured Israel’s security, and that “established traditions of the Zionist movement in Israel are consistent with the values that I have tried to live by.” He added later that even if Israel continues expanding settlements, robust support for Israel in Congress means “the United States will still be there” as an ally.

Obama’s administration brought Israelis and Palestinians to the negotiating table twice, in 2010 and 2013-14, each time unsuccessfully. Obama told Dayan that Israel’s military advantage gives it the ability to take risks for peace. The president signed a 10-year, $38 billion defense assistance agreement with Israel in September.

“I will do everything necessary to make sure Israel is in a position of strength, that it can defend itself by itself,” he said. “Because of that strength, then, you are in a position to take some risks for peace. Not stupid risks, not reckless risks, but some risks.”

Israel objected to the recent Security Council resolution in part because the measure deemed eastern Jerusalem occupied territory, including the Western Wall. Israel annexed eastern Jerusalem in 1980, a move that few countries recognize. Obama said U.S. administrations have long considered the area occupied.

“All of us would recognize that in any final resolution, there are portions of what would be considered currently as occupied territory that would become part of Israel,” he said. “That’s when strategic depth comes in, that’s when historical issues like the Western Wall would come into play.”

Israel has also demanded the United States block any further Security Council resolutions on the conflict. Obama said Tuesday that his administration would veto any resolution that predetermined the outcome of Israeli-Palestinian peace talks.

“A resolution that outlines [a] final status, that would not be appropriate,” he said. “Because the truth is this won’t get solved unless the Israeli people and Palestinian people want to solve it.”

Obama and Netanyahu had an often acrimonious relationship, clashing over settlement building, peace talks and — more than anything — the 2015 agreement on Iran’s nuclear program. The agreement, negotiated between Iran and six world powers led by the U.S., freezes Iran’s nuclear activities in return for a lifting of sanctions.

Netanyahu lambasted the deal as a capitulation to Iran, including in a controversial speech before Congress in 2015. But Obama said Tuesday that Israeli officials agree the pact has helped Israel.

“Israeli military and intelligence teams say this deal works to achieve the narrow goal that we set out,” Obama said. “I was called someone who was betraying Israeli interests, and we actually have proof now, because we can take a look, and lo and behold, my tough-minded negotiation … has resulted in a much lower possibility of one of Israel’s most powerful enemies obtaining a weapon that would threaten Israel’s existence.”

Obama said Netanyahu “had a good friend, it’s just Bibi didn’t always recognize it.” The president suggested that if his successor, Donald Trump, supports Israeli policy no matter what, it could hurt Israel’s long-term interests.

“Unfettered support for Israel, and support for the Netanyahu government’s policies, no matter what they are, no matter how inimical they may be to the prospect of peace, if that’s what qualifies as a good friend, I believe we will see a worsening situation over time,” he said.

Referring to the Israeli prime minister, Obama questioned “whether he’ll sleep better after Jan. 20.”