By Laila Kearney

(Reuters) - Hundreds of people were rescued from a smoldering passenger ferry ship that caught fire off Puerto Rico on Wednesday, the U.S. Coast Guard said.

The Coast Guard and local police brought ashore all 512 passengers and crew from the American Cruise Ferries vessel that was burning about two miles (3.2 km) off of San Juan, Puerto Rico's capital, the Coast Guard said in a statement.

Rescue crews worked for hours to remove passengers and ferry employees, the last of whom disembarked just after 2 p.m. EDT (1800 GMT), the Coast Guard said. They were transported to San Juan.

The fire, which was reported at about 7:40 a.m. EDT, began in the engine room of the ship and spread to other compartments on board, the Coast Guard said.

"Everyone has been safely removed from the ship," the Coast Guard said.

Smoke billowed from several parts of the large white ferry as an inflatable orange rescue slide was activated, images posted by Puerto Rico police on social media showed.

The 561-foot-long (171-meter-long) ferry, en route to the Dominican Republic, eventually ran aground about 800 feet offshore, the Coast Guard said.

American Cruise Ferries takes tourists from San Juan to Santo Domingo, Dominican Republic, according to the travel company's website.

Coast Guard officials could not be reached for further comment.

(Reporting by Laila Kearney in New York; Editing by Jeffrey Benkoe and Alan Crosby)