Running at their highest levels in six years, U.S. refineries are finding strong demand for diesel fuel, used widely in cars outside of the United States, and other distillates, like jet fuel.

"Any companies with refining assets on the Gulf Coast are expanding their export terminals,” said Fadel Gheit, senior energy analyst at Oppenheimer, citing Valero, Shell and Marathon Petroleum. “The profitability is not that clear, but the trend is very clear."

The U.S. became a net exporter of petroleum products just two years ago and is now the largest exporter in the world.

The product of choice for export is diesel because the margins are much higher and demand is growing, and U.S. refiners have an advantage over foreign counterparts. Natural gas to fire up refineries is abundant and much cheaper in the U.S., and the expansion of U.S. oil production has made oil more plentiful and cheaper than if refiners had to buy it on the world market.

Gulf Coast product margins

The race is on to add capacity, and mainly for diesel. Diesel demand is growing at twice the rate of gasoline, demand for which has been declining in the U.S. Gasoline demand has been declining and is expected to continue declining, as drivers shift to more fuel-efficient vehicles.

(Watch this: Epperson: Crude oil inventories down 1.32 million barrels)

Valero, the world's largest independent refiner, completed building two new hydrocrackers, one last year at its refinery in Port Arthur, Texas, and another last month in St. Charles Parish, La. Each cost about $1.5 billion and can process 60,000 barrels of petroleum feed stocks a day.

"We're talking about expanding them to make them even larger and we may expand an existing hydrocracker at another existing refinery," said Valero spokesman Bill Day.

Valero in the Atlantic basin

Gulf Coast refineries have had an advantage compared to their counterparts on the East Coast, where a lot of refining capacity has been shut down over the past several years because of their reliance on then much higher priced Brent crude. The addition of pipeline capacity and rail shipments from the middle of the country has brought more U.S. crude into the Gulf, displacing African oil. Rail has also benefited East Coast refiners, who now receive mid-continent crude.

(Read more: China data may wrong-foot oil bears)

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Andrew Lipow, president of Lipow Oil Associates, said that imports are headed predominantly to New England and the East Coast. Exports, he said, depart from the Gulf Coast.

"We rarely are shipping gasoline from the Gulf Coast to the state of Maine or Boston,” Lipow said. “Those imports are being supplied by Canada and Europe. If we were to supply them off the Gulf Coast, we'd need an American flagged tanker to do it, which is expensive.”

He said it’s cheaper to import from Europe and Canada than bring in oil from the Gulf Coast to Latin America and the Caribbean.

Government data show the U.S. exported 1 million barrels a day of diesel fuel for the week ended Aug. 2, about the same as the last several weeks, but up from 840,000 barrels a week earlier in the summer. The U.S. industry has increasingly found foreign buyers for petroleum products, mostly diesel but also jet fuel and some gasoline.

According to Bank of America Merrill Lynch, U.S. exports rose to 2.6 million barrels per day by the end of 2012, from 1.3 million in 2007. Wednesday's data showed exports of 2.9 million barrels per day in the past week. The U.S. imported 700,000 barrels of gasoline per day in the week, while exporting 258,000 barrels a day of finished gasoline.

Valero says it is responsible for about 20 to 25 percent of U.S. exports, and it exports 15 to 20 percent of the diesel it produces, and about 8 percent of the gasoline, Day said. In the second quarter, Valero was producing 1.3 million barrels a day of gasoline and 910,000 barrels of distillates, which include fuel oil, jet fuel and diesel.

(Read more: Energy futures prices)

"Export is our safety valve. We cannot make a lot more product that can be sold into the U.S.. Demand is not growing," said Gheit.

(Read More: Big oil struggles to reap profits from US energy boom)

Refined product export growth

Analysts also say U.S. petroleum products are probably slightly more expensive because of the export market, but it's hard to say how much. While refined products can be exported, raw crude oil cannot be.

"If the U.S. did not allow petroleum product exports, you would have much lower petroleum prices here at home. You would lose refining capacity but you would have lower prices domestically and you would have a higher price internationally," said Francisco Blanch, head of global commodity and asset allocation research at Bank of America Merrill Lynch.

"There are a number of reasons that U.S. refiners are very competitive. The fact that crude cannot be exported is one of the reasons," he said.

John Kilduff, oil analyst with Again Capital, said the price of diesel and crude are both higher because of the ability of U.S. refiners to meet some of the demand from abroad. "The U.S. was the bread basket to the world. Now we're the refiner to the world," he said.

Blanch said he expects gasoline demand in the U.S. to drop fairly dramatically over the next 15 as years as drivers switch out of old cars, and new cars become ever more fuel efficient.

"In some ways, it's a good thing the U.S. is exporting this. It is improving the balance of payments of the U.S.," he said.

Blanch said the U.S. move toward energy independence also gives the U.S. a growth advantage over Europe and Japan.

(Watch this: Santelli: The good news on energy)

"We calculate that it may lead to as much as 1.5 percent of GDP additional output for the U.S. relative to Europe every year, as long as the current natural gas price differential persists," he said.

Lipow said if there were no exports of refined product, consumers would be paying the price of a less healthy refining industry. "If we didn't export this stuff, we would simply shut down refineries and prices may or may not be higher or lower than they are today, but we would certainly lose capacity,” he said. “If we were to shut down those refineries, they get shut down forever so if other refineries were offline, there'd be no slack in the system and we would end up with gasoline shortages."

—By CNBC's Patti Domm. Follow her on Twitter @pattidomm.