In the run-up to President Trump’s trip to Saudi Arabia last year, senior White House aide Jared Kushner and Crown Prince Mohammed bin Salman spoke nearly every day.

Mr. Kushner, the president’s son-in-law, worked to lock in Saudi pledges and make certain Mr. Trump wouldn’t come away embarrassed from his maiden trip overseas, a person familiar with the matter said.

At the conclusion of the two-day trip to Riyadh, Mr. Kushner and the White House believed Saudi Arabia had delivered, with commitments to combat terrorism and to make billions of dollars in U.S. investments.

The May 2017 trip was a major foreign-policy gamble with roots in the previous year’s presidential transition. It arose from a hope that the Trump White House could improve ties with the kingdom and reap considerable rewards.

But the killing of Saudi dissident Jamal Khashoggi at the hands of Saudi operatives has made that bet riskier and confronted Mr. Trump with a dilemma: how to punish the kingdom without jeopardizing an alliance he has spent two years cultivating.