PANAMA CITY, Fla. — With Hurricane Michael gaining strength and bearing down on the Florida Panhandle, people in the storm’s path hurried to stack sandbags, fill gas tanks and stock up on bottled water in the final hours before the arrival of a system many said took them by surprise.

The looming storm — forecast to make landfall as a major hurricane on Wednesday afternoon — set off a flurry of evacuation orders and canceled flights along Florida’s Gulf Coast. Shelters opened and schools shuttered, in some cases for the rest of the week.

“It came on so quickly,” said Larry Messinger, a Red Cross coordinator at a shelter in Panama City. “A week ago, I don’t think anyone in this area was paying attention, and all of a sudden, there is a hurricane.”

Forecasters say Michael, which strengthened to a Category 4 hurricane early Wednesday, will make landfall in northwest Florida at that strength, bringing with it unforgiving winds, pounding rains and a “life-threatening storm surge” that the National Hurricane Center said could reach 13 feet in some areas.

Governors in Florida, Alabama and Georgia declared emergencies while awaiting the system, which is expected to head northeast after swamping the coastlines.

“Let me be clear: Hurricane Michael is a monstrous storm,” Florida Gov. Rick Scott (R) said at a briefing. “And the forecast keeps getting more dangerous.”

Much of this was happening in a region that has rarely experienced major hurricanes making landfall in the modern era.

Hurricane Michael moves across the Florida Panhandle

Waves crash against the M.B. Miller County Pier in Panama City Beach, Fla., as Hurricane Michael approaches.

“Hurricane Michael is going to be a devastating storm to a part of Florida that has not seen a storm of this magnitude in quite some time,” FEMA Associate Administrator Jeff Byard said Tuesday.

Hurricanes are categorized based on wind speed, but even storms on the weaker end of that scale can wreak havoc across communities — with the storm surge a particular focus of authorities awaiting Michael’s arrival.

“A very dangerous storm surge will occur along the coast and well inland,” Ken Graham, director of the National Hurricane Center, said in a briefing Tuesday.

Storm surge, a swell of water fueled by a system’s winds, has been the leading cause of death from hurricanes in the United States, according to the National Weather Service.

The hurricane came on suddenly compared with the plodding, days-long approach of Hurricane Florence before it made landfall in the Carolinas last month, flooding much of that region and killing dozens of people.

President Trump approved an emergency declaration in Florida on Tuesday. In remarks at the White House, he said officials were “very well prepared” for the storm, which he said was “a big one — much bigger than they anticipated a week ago.”

On the ground in northwest Florida, preparations quickly unfolded before the storm arrived. Sandbags were distributed across the region, while residents hunkering down sought to gather supplies, though some encountered gas stations already sucked dry and grocery stores picked clean of bottled water.

In Panama City, more than 160 people had camped out at Northside Elementary School, one of two shelters in Bay County, by Tuesday afternoon. Volunteers with the American Red Cross said the storm’s sudden approach didn’t give them much time to respond and equip the shelters with cots or blankets.

Some residents said they were just thankful for a place to wait out the storm. Leticia Hernandez said she decided to take her four children to the shelter from their home in a waterfront community of Panama City that is prone to flooding. They settled in a corner of a school hallway on an inflatable bed, playing board games.

Hernandez said she learned about the storm Sunday night and had just enough time to gather food and supplies and to find a safer place for her family to spend their first hurricane in Florida.

“I thought about the devastating flooding from Hurricane Harvey in Texas, and I didn’t want to risk it,” she said.

After hitting the coast, Michael is expected to weaken as it grinds across the southeastern United States, parts of which are still recovering from Florence. Forecasters warn that the dangers stretch far from the coastline, with heavy rainfall potentially extending across Florida, Alabama, Georgia, the Carolinas and southern Virginia, causing dangerous flash floods.

“It’s not just a coastal issue,” said Graham, the hurricane center’s director, warning that people will “start seeing this rain, start seeing this wind stretch further inland.”

These concerns have stretched inland as well, where officials across other neighboring states warned residents to be wary and ready “for whatever Michael may bring,” as Alabama Gov. Kay Ivey (R) put it when she announced a state of emergency there.

In Tallahassee, the Florida capital that sits 25 miles from the coast, parts of the city shut down Tuesday. Florida State University closed its campus and said it would reopen next week; City Hall shuttered at noon, with officials heading to the Emergency Operations Center.

At the Apalachee Regional Park, Tallahassee residents stood under a baking sun Tuesday to fill sandbags they hope will hold back the expected flooding. Some said they had stocked up on water, gas and food before getting to work here — with more work still planned.

“We have a whole hog and cow in the freezer so we’re going to grill and we’re going to fry,” said Gwendolyn Thomas, 55, a retiree from the state highway safety department, as she and her husband worked nonstop on filling sandbags. “This was not supposed to be part of retirement.”

In Panama City, the sun was out and the breeze was pleasant midday Tuesday, making it hard to believe a major hurricane was just a day away, Donna Self said.

“You can tell the winds are picking up,” Self, a lifelong Panama City resident, said as she pushed a cart full of supplies from the local Walmart, just outside the city. “Based on the news, it looks like Panama City is a direct hit.”

Self wasn’t worried. She and the home where she’s lived for 30 years have survived various hurricanes. “Opal was pretty awful,” she recalls. She didn’t evacuate for that one, and she wasn’t going to leave for Michael. “I am nervous but I choose to try to be relaxed, because we can’t do anything about it.”

Berman reported from Washington. Patricia Sullivan in Tallahassee, Carmen Sisson in Pensacola, Fla., and Kevin Begos in Apalachicola, Fla., contributed to this report.