The U.S. Supreme Court upheld President Donald Trump’s travel ban against a broad legal attack, giving him a legal and political victory on a controversy that helped define his presidency.

The vote Tuesday was 5-4 along ideological grounds. The court rejected contentions that Trump had exceeded his authority and violated the Constitution by targeting Muslims.

The ruling ends a legal saga that dates to the beginning of the Trump presidency and helped define his assertive, divisive leadership style. The decision bolsters the president’s already broad control over the nation’s borders.

A Hawaii-led group of challengers at the Supreme Court said...