It looks like Secretary of State John Kerry is determined to go out the way he came in — wrapping himself in the flag while betraying the causes of both America and its allies. He came in by doing that to Vietnam and is going out by turning on Israel.

Kerry’s tirade against Jewish settlements in liberated Judea and Samaria was breathtaking in its mendacity.

Before a captive audience at the State Department, the lame-duck diplomat went on for more than an hour, blaming President Obama’s failures (and his own) almost solely on the Jewish state.

The secretary tried to haul out of history’s dustbin what is known as UN Resolution 181. That envisaged wresting Jerusalem away from the Jewish state altogether and putting it into the possession of an international regime. It’s been a dead letter for decades.

In one of the most condescending speeches ever given at the State Department (no mean feat), Kerry spoke as if he knows better than Israel, the Mideast’s only democracy, what is best for Israel. Affecting friendship, he helped only its enemies.

Just as he helped our enemies, years ago, in respect to Vietnam — another struggle that pitted the partisans of freedom and democracy against the allies of totalitarianism. That’s where perfidy started to glint in Kerry’s career.

Once a gung-ho officer in the Navy, he fell away and became what the American Revolutionary War pamphleteer Thomas Paine called a “summer soldier.” Kerry, ashamed of the idea, liked to refer to the anti-war movement as “Winter Soldiers.”

What a mockery of the spirit of Valley Forge.

Kerry even traveled to Paris to treat with our Communist enemies. Then he came home and made their arguments in the public arena, all in the hopes of getting America to abandon free Vietnam. It was the start of his long climb in American politics.

Now Kerry has apparently tired of the struggle for a safe and secure Jewish state, though one American administration after another — Republican and Democratic — held the line at the Security Council. Kerry organized an abstention on a resolution that says it’s illegal for Jews to settle in Judea and Samaria — and Jerusalem, inviting a claim that the remnants of the Second Temple are “occupied” Palestinian territory.

How this would’ve pleased J. William Fulbright, the senator who ushered Kerry into public life — and in whose views one can see Kerry’s intellectual development on both Vietnam and Israel. It was the Arkansas Democrat, then chairing the Foreign Relations Committee, who brought Kerry up to Capitol Hill to accuse American GIs of committing war crimes in Vietnam.

One anti-war senator, George Aiken, asked young Kerry whether he thought the North Vietnamese Communists “might help us carry our bags” as we quit the battlefield. “They would be more prone to do that than the Army of the South Vietnamese,” Kerry quipped, provoking laughter in the Senate.

Golda Meir, then Israel’s prime minister, was onto Fulbright’s game. “Can you remember when Sen. Fulbright has said anything positive about Israel?” she once asked an interviewer after Fulbright complained that the Senate was “subservient” to the Jewish state.

Fulbright once delivered at Kerry’s alma mater, Yale, a notorious speech touching on both Vietnam and Israel and the Palestinian Arabs. “It makes no sense at all,” Fulbright said, “for us to shrink in horror at the very notion of an ‘imposed’ solution.”

Kerry’s mentor said that he regretted that no such settlement “seems possible in Vietnam,” according to the phrasing of the Associated Press. But in the Middle East, Fulbright asserted at Yale, America had a “positive responsibility to bring an influence to bear.”

In the context of this history, Kerry’s speech Wednesday is not just a transparent attempt at shifting onto Israel blame for his own failures in peace negotiations he should never have entered. It’s his final effort to redeem the leg up he was given by old man Fulbright.

Who was, by the way, an arch-segregationist, like so many Southern Democrats of the era. That lends a certain irony to Kerry’s attempt in his speech Wednesday to liken the Palestinian Arab cause to America’s civil rights struggle (which doesn’t deserve Kerry’s comparison).

It’s hard to recall anything quite like Kerry’s campaign to box in the freely elected government of Israel and Donald Trump’s incoming administration. It’s a reminder of what Lincoln said about how one can’t fool all of the people all of the time.