Jamal Khashoggi walked into the Saudi Consulate in Istanbul in October 2018 to obtain documents for his coming wedding. His fiancee was waiting outside.

He never emerged. He was drugged and dismembered, cut apart with a bone saw. No part of him has been seen since. He was erased from the Earth by agents of the Saudi Arabian government acting, American intelligence officials believe, on the orders of Crown Prince Mohammed bin Salman.

Khashoggi lived in the United States and worked for this newspaper. His murder was a brazen and ostentatious act, a statement from the Saudi government about its views of an open press and its ability to strike at its enemies anywhere in the world.

President Trump’s response to the killing has been consistently sympathetic — not to Khashoggi and the principles of government accountability, but to the crown prince and the Saudis. He repeatedly insisted Khashoggi’s death shouldn’t put at risk more than $100 billion in arms sales — a figure that was wildly inflated. It was an unexpected response from an American president, if not an entirely unexpected one from Trump.

A few weeks after Khashoggi vanished, after it had been established by the intelligence community that the crown prince — or MBS, as he’s known — bore culpability for the death, Trump released an unexpected statement defending the Saudis’ foreign policy efforts.

“The world is a very dangerous place!” it began. After touting those arms deals, he lamented Khashoggi’s death. Then, an unstated “however.”

“Representatives of Saudi Arabia say that Jamal Khashoggi was an ‘enemy of the state’ and a member of the Muslim Brotherhood,” the statement read, “but my decision is in no way based on that — this is an unacceptable and horrible crime.”

“King Salman and Crown Prince Mohammad bin Salman vigorously deny any knowledge of the planning or execution of the murder of Mr. Khashoggi,” it continued. “Our intelligence agencies continue to assess all information, but it could very well be that the Crown Prince had knowledge of this tragic event — maybe he did and maybe he didn’t!”

“That being said, we may never know all of the facts surrounding the murder of Mr. Jamal Khashoggi,” it went on. “In any case, our relationship is with the Kingdom of Saudi Arabia.”

Again, there was no obvious prompt for the statement. No obvious urgency demanding Trump step up to cast doubt about MBS’s culpability or to smear Khashoggi’s reputation. Just an out-of-the-blue what-are-ya-gonna-do about the death of a guy from Virginia murdered as he was trying to finalize plans for his marriage.

On Wednesday, we learned about an apparent motive, if not the apparent motive: Trump released the statement to draw attention away from questions about his daughter Ivanka Trump’s use of a private email account while working for Trump’s administration.

Former national security adviser John Bolton’s coming book, which The Post’s Josh Dawsey obtained before its release next week, describes Trump’s motivation for the statement. The day before its release, Newsweek reported Ivanka Trump had been using her personal email to communicate with Cabinet officials and others within the government. In September 2017, 10 months into Trump’s presidency, Ivanka Trump’s attorneys sorted through her messages to ensure she was complying with federal records laws.

In a normal moment, this would have been a minor issue. Under Trump, though, it was a problem: He’d repeatedly excoriated Hillary Clinton’s use of a private email server during the 2016 presidential election and he’d repeatedly faced questions about the suitability of assigning his daughter to a senior government position.

So: a statement depicting a murder victim as perhaps being culpable in his own death and defending the individual believed to have ordered the murder.

“This will divert from Ivanka,” Trump said, according to Bolton's book. “If I read the statement in person, that will take over the Ivanka thing."

“Why didn’t she change her phone?” the president asked rhetorically, according to Bolton. “What a mess we have because of that phone!”

It’s worth pointing out that this is precisely what Trump’s most fervent critics have accused Trump of doing: using contentious comments as intentional diversions. It would be hard to broadly differentiate between things which are sincere, in-the-moment reactions from the president and things which are intentionally combustible and designed to shift attention. In this case, though, Bolton claims that the latter was specifically what was intended.

To put a fine point on it, Trump thought it was preferable to be seen as treating an accused murderer with kid gloves and to prompt questions about his interactions with MBS to having people scrutinize the behavior of an official within his government who happened to be his daughter.

It worked. The story about Ivanka broke late on Nov. 19, 2018. A bit after noon on Nov. 20, Trump released the statement. A few hours later, he left the White House for Mar-a-Lago, fielding questions from reporters before boarding Marine One.

Internet Archive closed-captioning data compiled by GDELT show how MSNBC and CNN’s conversations about Ivanka were largely redirected to a discussion about Saudi Arabia after the statement and after he discussed the statement with reporters. Fox News, which hadn’t been covering Ivanka much, pivoted to Saudi Arabia as well.

He successfully shifted the attention of those reporters asking him questions outside the White House to some extent as well. Of the two dozen questions he was asked, six were about Saudi Arabia and two about Ivanka Trump’s emails.

But of course, the president appearing to wave away concerns about the murder of a U.S. journalist at the hands of a foreign power is a more important story than an official’s use of a private email account. It’s not as though the reporters should have ignored Trump’s statement or that they were distracted by something useless. It’s that Trump took a formal position that warranted that scrutiny.

“Are you letting the Saudis get away with murder — murdering a journalist?” a reporter asked as Trump was preparing to head to Florida.

“No, no. No, no. This is about ‘America first,’ ” Trump insisted. “They’re paying us $400 billion-plus to purchase and invest in our country. That’s probably the biggest amount ever paid to the United States — this is over a long period of time. It means hundreds of thousands of jobs, billions of dollars of investment and product.”

Those claims aren’t true.

What the revelation from Bolton also reinforces is that Trump is motivated more by short-term, cable-news victories than his legacy over the long term. To get CNN to stop covering the hypocrisy of his daughter’s actions, he formalized his own position on Saudi Arabia’s actions and its treatment of journalists.

Of course, that links to another part of Bolton’s book as reported by Dawsey.

“These people should be executed,” he said of journalists who wouldn’t reveal their sources, according to Bolton. “They are scumbags.”