By Gabriel Stargardter and Harriet McLeod

MIAMI/CHARLESTON, S.C. (Reuters) - People along the southeast U.S. coast fled inland, stocked up on groceries and queued for gasoline on Wednesday as President Barack Obama and state governors urged millions to evacuate or brace for a potentially devastating Hurricane Matthew.

Matthew pummeled the Bahamas and took aim at the United States as the fiercest Caribbean storm in nearly a decade, appearing likely to hit Florida with powerful winds, storm surges and heavy rain on Thursday, the U.S. National Hurricane Center said.

"I want to emphasize to the public - this is a serious storm," Obama said after a briefing with the Federal Emergency Management Agency. "If there is an evacuation order in your community, you need to take it seriously."

Federal emergency response teams had arrived in Florida, Georgia, South Carolina and North Carolina, and were coordinating with state officials and stockpiling supplies, Obama said. Governors in those states have declared states of emergency, enabling them to mobilize the National Guard.

Matthew, a major Category 3 storm, had sustained winds of about 115 miles per hour (185 km per hour) on Wednesday night, the Miami-based hurricane center said, adding that it was too soon to predict where Matthew was likely to do the most damage.

South Carolina Governor Nikki Haley has ordered an evacuation of more than a million people in coastal areas, about a quarter of whom were expected to comply.

In Georgia, Governor Nathan Deal expanded a state of emergency declaration to include 17 additional counties in the southeastern part of the state, bringing the total to 30 counties, his office said late on Wednesday.

Florida Governor Rick Scott urged those in vulnerable areas to evacuate early, even if orders had not yet been issued, and to use state shelters.

Scott requested that Obama declare a pre-landfall emergency for Florida, which would bring federal resources such as food, water and tarps, and added an additional 1,500 National Guard members to an already active force of 1,500.

Evacuations, some of them mandatory, were underway in about a dozen of Florida's coastal counties, and at least four hospitals were being cleared, Scott said. More than 1.5 million Florida residents reside in evacuation zones, Scott's office said.

"If it turns at the last minute, you are not going to have time to get ready," Scott said. "You are going to put your life and your family's life at risk."

In South Carolina, where the effects of the storm were expected on Saturday morning, drivers reported gridlock and long delays. The city of Charleston handed out sandbags and shovels.

Some gasoline stations posted "out of gas" signs but state officials said they were unaware of any significant shortages.

Lynn Pagliaro, 76, was filling up extra cans of gasoline and loading them into his sport utility vehicle in Charleston, saying he had no choice but to head inland.

"I live at (a retirement community) and they're shutting off the power," he said. "I like to get out of town anyway and take the burden off local resources. I was here for Hurricane Hugo. It made a last-minute turn."

Hugo, a more powerful Category 4 hurricane, slammed into Charleston in September 1989, killing 21 people and causing $7 billion worth of damage on the U.S. mainland, the hurricane center said.

In Miami, the owner of an Exxon gas station in the Brickell district set up cones to form an orderly line of cars that at times stretched an entire block.

"Everybody is filling up. We’re about to run out of gas," said Jesus Ramirez, 56.

At a nearby Publix supermarket, staff said trade was brisk with customers buying water and canned goods, concerned they might be stuck at home for days. "It's chaos," said one employee, who was not authorized to speak to reporters.

Floridians on social media said they were stocking up on groceries and preparing their homes with hurricane shutters.

"The grocery store shelves are practically empty," said Facebook user Sonja Smith of Boca Raton, Florida.

American Airlines said it was canceling Thursday flights at three south Florida airports and all Friday afternoon flights in and out of Jacksonville.

(Additional reporting by Letitia Stein and Amy Tennery; Editing by Daniel Trotta, Tom Brown and Lisa Shumaker)