What happened

Shares of refiners Phillips 66 (PSX -0.40%), Valero Energy (VLO -1.01%), and Marathon Petroleum (MPC -0.69%) all tumbled in May, falling between 12% and 23%, according to data provided by S&P Global Market Intelligence. Several issues weighed on these downstream stocks last month.

So what

Refining companies are under pressure on several fronts. The growing trade tensions between the U.S. and China have negatively impacted demand for refined products this year, which is cutting into refining profit margins. That issue was evident in the first quarter as earnings dropped across the sector. On top of that, the U.S. announced plans last month to impose new tariffs on Mexico in hopes of forcing that country to take actions that could help solve America's immigration issue. Those fees, however, could cause Mexico to ship less of its oil to the U.S., which would increase refining costs since they'd have to replace this oil with higher-priced crude from other countries. Meanwhile, flooding in the Midwest caused several pipelines to shut down, impacting the flow of oil and refined products.

Refinery at twilight with a beautiful sky in the background.

Image source: Getty Images.

The challenging operating conditions in the refining market had a direct effect on Marathon Petroleum during the first quarter. That was quite clear in the results it reported last month, which missed analysts' expectations by a wide margin as the company posted a loss of $0.09 per share while the consensus was that it would earn $0.18 per share. The main issue were its margins, which were much weaker than expected. Analysts thought that Marathon Petroleum would capture a refining margin of $13.85 per barrel during the quarter. Instead, it only earned $11.17 per barrel due to the issues affecting the refining market. That disappointing result caused shares of the refining giant to tumble.

Valero and Phillips 66 also reported weaker first-quarter results, though both announced their numbers in late April, so those reports didn't have as much of a direct impact on their stock prices last month. Still, these reports showed just how tough conditions are for refiners these days. In Phillips 66's case, its earnings fell by more than 50% because of a similar decline in its refining margin. Both were under pressure due to higher Canadian oil prices and major maintenance projects at five of its facilities, which impacted output. Valero, in the meantime, reported a 41% earnings decline in its refining segment, though its margins weren't under quite as much pressure -- they only fell by about 10%.

Now what

While May was a rough month for refining stocks, several analysts believe that the worst might be over for the sector. Cowen, for example, sees a buying opportunity in Valero and Phillips 66, noting that "trade concerns are weighing on the overall group more than improving refining margins." However, JPMorgan upgraded Valero's stock to overweight last month. Driving its positive view is the expectation that conditions in the refining sector will improve over the next six months, especially as new oil pipelines come on line and increase the flow of cheaper crude oil from the Permian Basin to refining markets along the coast of Texas.