WASHINGTON—President Donald Trump said on Wednesday he was weighing permitting foreign-flagged vessels to ship relief supplies from U.S. ports to storm-ravaged Puerto Rico, but noted U.S.-based maritime carriers opposed the move.

Mr. Trump’s remarks came after a group of House Democrats and Republican Sen. John McCain of Arizona asked the Department of Homeland Security to waive the restrictions, contained in a 1920 law called the Jones Act, which they say will burden the relief effort and increase the cost of bringing critical supplies to islanders.

“We’re thinking about that,” Mr. Trump told reporters when asked if he would lift restrictions on foreign vessels’ operations, “but we have a lot of shippers and a lot of people... who work in the shipping industry that don’t want the Jones Act lifted. And we have a lot of ships out there right now.”

The act, regarded as one of the cornerstones of U.S. maritime policy, requires that goods shipped between U.S. ports be carried by vessels built in the U.S., majority-owned by American firms and crewed by U.S. citizens. The Department of Homeland Security hasn’t waived the act for Puerto Rico, which was devastated by Hurricane Maria last week.

The Category 4 storm destroyed the island’s electrical grid and left it desperately short of food, clean water and fuel.

U.S.-based carriers and the Department of Homeland Security maintain the problem hindering the relief effort isn’t a lack of ships, but devastation to the island’s transportation network and a shortage of diesel fuel.

Related Video Hurricane Maria slammed into the Caribbean islands early this week, leaving millions of people without power. Here is what you need to know. Photo: Getty Images

“Our current assessment is that a waiver isn’t needed,” DHS spokesman David Lapan said. “We don’t believe the Jones Act is preventing us from moving goods to Puerto Rico by sea.”

Michael Roberts, senior vice president and general counsel at Crowley Maritime Corp., a Jacksonville, Fla., carrier that benefits from the Jones Act’s protection, said there is “a very steady pipeline of relief goods that is in process now and adding foreign-flag capacity and taking out U.S. mariners who are doing this work would not help at all.”

Another tanker company executive, who asked not to be named, said, “We just can’t move trucks to depots and gas stations. The roads are a mess.”

The Jones Act has been suspended in past natural disasters to allow cheaper, foreign-flagged ships bring in aid. President George W. Bush suspended it after Hurricane Katrina in 2005 and President Barack Obama suspended it after superstorm Sandy in 2012.

In a letter sent to the Department of Homeland Security on Tuesday, Mr. McCain criticized the department for waiving the Jones Act in the wake of hurricanes Harvey and Irma, but not for Puerto Rico. Mr. McCain has long sought a repeal of the Jones Act.

“It is unacceptable to force the people of Puerto Rico to pay at least twice as much for food, clean drinking water, supplies and infrastructure due to Jones Act requirements as they work to recover from this disaster,” he wrote in the letter sent Tuesday evening.

Seven House Democrats, led by Rep. Nydia M. Velázquez of New York, sent a letter Monday to acting DHS Secretary Elaine Duke urging a one-year waiver and requesting Puerto Rico be exempted from requirements that local resources match federal funds expended by the Federal Emergency Management Agency.

“In their hour of need, Washington can help by suspending the Jones Act and suspending cost-sharing obligations,” the House Democrats wrote.

Mr. Lapan said the letter wasn’t received by DHS until Wednesday, causing a delay in a review of the waiver request.

“We finally found today that the letter had been put in regular mail,” he said. “We didn’t actually receive the later until this afternoon.”

Crowley Maritime and TOTE Maritime, U.S.-based ocean carriers that are the main operators serving Puerto Rico, together have brought in roughly 6,000 shipping containers, mostly packed with relief supplies, since the San Juan port reopened on Saturday. The companies said most of those containers were still at the port waiting to move inland even as more ships with relief supplies were scheduled to arrive in the coming days.

A senior DHS official said Wednesday the Jones Act doesn’t permit the department to grant waivers simply to push down costs. Only the Department of Defense may obtain a Jones Act waiver automatically, which it did to move petroleum products from Texas after Hurricane Harvey. If a request comes from another agency or person, such as a member of Congress, DHS conducts an analysis to determine whether U.S.-flagged ships can accommodate the needs before granting it, Mr. Lapan said.

The White House is expected to send Congress a request for a funding package for Puerto Rico in the next few weeks, a senior congressional aide said. The aide said that Puerto Rico may access the $15.25 billion appropriated earlier this month after Hurricanes Harvey and Irma struck Texas and Florida.

—Rebecca Ballhaus contributed to this article.

Write to Natalie Andrews at Natalie.Andrews@wsj.com and Paul Page at paul.page@wsj.com