Shares of energy companies rose slightly amid deal activity and a surge in natural gas prices.

Refining giant Marathon Petroleum agreed to sell its Speedway gas station chain to the Japanese owners of the 7-Eleven convenience store chain for $21 billion in the largest U.S. energy deal of the year.

The urgency on Marathon's side to strike the deal was clear from its second-quarter earnings report, as it posted a steep drop in net profit, reflecting the slowdown in fuel consumption during nationwide lockdowns.

Natural gas prices surged 17% to $2.10-per-million-British thermal units, the highest closing price since May 5, as forecasts for a warmer-than-expected August spurred bets on higher energy usage. Utilities often burn more natural gas when demand for air-conditioning rises.

Write to Rob Curran at rob.curran@dowjones.com