A federal judge ordered pilots at Allegiant Travel Co. to halt a planned strike, a last-minute court decision to prevent spiraling labor discord at the discount carrier from disrupting thousands of travelers.

Judge Gloria Navarro of the U.S. District Court in Nevada on Wednesday approved Allegiant’s request for a temporary restraining order against the Allegiant pilots’ union’s plans to strike on Thursday.

The...