SEOUL, South Korea — President Trump on Wednesday tried to make a surprise, unscheduled visit to the demilitarized zone separating North and South Korea, but he was foiled by dense fog that prevented his helicopter from landing near one of the world’s most dangerous borders.

Slipping out of his hotel in the darkness of a foggy morning, Mr. Trump boarded the Marine One helicopter to make the journey, which aides had said the president would skip during his stop here during a 12-day, five-country tour of Asia.

Sarah Huckabee Sanders, the White House press secretary, took unusual precautions in briefing reporters traveling with Mr. Trump about the visit, swearing them to secrecy until he returned, citing the security risks of the trip.

“This is where we’re going,” Ms. Sanders told reporters, holding up a piece of notepaper on which the letters “DMZ” were scrawled. The caution turned out to be for naught. Mr. Trump’s helicopter lifted off from an American military base in Seoul, the South Korean capital, and flew north, coming close to the demilitarized zone, but after 25 minutes in the air, White House officials said there had been a “bad weather call,” and there was insufficient visibility for the president to land.