Rising energy company sharesOpens a New Window. boosted major averages Thursday, giving the S&P 500 its first gain in three days, after two oil tankersOpens a New Window. near the strategic Strait of Hormuz were attacked.

All three major averages -- the Dow Jones Industrial Average, the S&P 500 and the Nasdaq Composite -- are on pace for their second straight week of gains.

One of the tankers carried oil bound for Japan, whose Prime Minister Shinzo Abe was wrapping up a high-stakes visit in Tehran that sought to ease tensions between Iran and the United States.

Secretary of State Mike Pompeo blamed Iran for the tanker attacks, calling the assaults part of a campaign of escalating regional tensions.

A third of all oil traded by sea passes through the strait, which is the narrow mouth of the Persian Gulf.

The price for West Texas Intermediate, the U.S. benchmark crude oil, rose 2.25 percent to 52.29 per barrel. Global crude oil benchmark Brent blend climbed as much as 4 percent. This comes a day after oil plunged more than 4 percent, weighed down by a weaker outlook for demand and a rise in U.S. crude inventories despite expectations of extended supply cuts led by OPEC. Read more at FOX Business