Clamouring aboard bamboo rafts and army trucks, residents living on the heavily inundated outskirts of Bangkok fled waterlogged homes on Thursday as floodwaters inched closer to the heart of the threatened Thai capital and foreign governments urged their citizens to avoid all but essential travel.

Most of the city remained dry and most of its more than 9 million residents were staying put to protect their homes. Still, uncertainty over Bangkok’s fate and the start of a government-declared five-day holiday fuelled an exodus of thousands of people fearing the worst who took to clogged highways and air terminals to get out of town.

Tears welling in her eyes, Prime Minister Yingluck Shinawatra acknowledged her government could not control the approaching deluge.

“What we’re doing today is resisting the force of nature,” Ms. Yingluck told reporters. She said the water bearing down on Bangkok was so massive that “we cannot resist all of it.”

The floods, the heaviest in Thailand in more than half a century, have drenched a third of the country’s provinces and killed close to 400 people. For weeks, they have crept down from the central plains, flowing south toward the Gulf of Thailand. Bangkok is in the way, and today it is literally surrounded by behemoth pools of water flowing around and through it via a complex network of canals and rivers.

By Thursday, flooding had inundated seven of Bangkok’s 50 districts, most on the northern outskirts. There, roads have turned into rivers and homes and businesses are swamped. On a flooded key east-west artery, police were turning back small cars, telling them the road had become impassable.

The government has expressed deep concern over higher-than-normal tides expected through the weekend. Ms. Yingluck has warned the entire city could flood if the Chao Phraya river, which snakes its way through the heart of the metropolis, crests above flood barriers lining its banks.

The river has overflowed already, sending ankle-high water lapping at the white exterior walls of Bangkok’s gilded Grand Palace, a highly treasured complex that once housed the kingdom’s monarchy and is a major tourist attraction.

The water has receded with the tides, slightly flooding the area in the morning and evening, but leaving it bone dry in the afternoon.

After visiting the Grand Palace on Thursday, American tourist Kathy Kiernan said she wasn’t too concerned about flooding in the capital.

“We were a little worried when we got in to see sandbags around our hotel,” said the 47-year-old from Salt Lake City, Utah. “But so far it’s pretty normal. Everything looks fine, though we know anything can happen.”

Though floods a day earlier swept through Bangkok’s Don Muang airport and shut it down, the city’s main international airport is operating as usual.

Several foreign governments issued advisories urging their citizens against all but essential travel to Bangkok. Britain’s Foreign Office said “flooding is likely to disrupt transport, close tourist attractions and may affect electricity and water supplies.”

The U.S. Embassy cautioned Americans that ground travel around Thailand was difficult and the situation should be monitored closely.

Buses, planes and trains at the city’s transportation hubs were filling up, as many decided to wait out the floods in their home towns or in unaffected beach resorts to Bangkok’s south and east.

As fears of urban disaster set in, emergency preparations continued.

Websites posted instructions on the proper way to stack sandbags. Many residents fortified vulnerable areas of their houses with bricks, gypsum board and plastic sheets. Walls of sandbags or cinderblocks covered the entrances of many buildings.

Residents stocking up on necessities have raided supermarket shelves, setting off a cycle of panic buying, and stores have posted notices that flooding has disrupted supply chains and left them unable to restock some items. But food was nevertheless plentiful, as most of the city’s thousands of restaurants, bars and street-side food stalls were operating full-swing.

Nuntaporn Khorcharoen, whose home is adjacent to the heavily inundated Bang Phlat district, said her family had stocked up and was staying put.

“My father is adamant we have to stay to oversee the situation,” the 30-year-old said. “He said even without electricity, we will still have something to live on.”

More In: International | News