By Nicole Jao

NEW YORK, July 17 (Reuters) – Oil prices rose nearly 5% on Friday after the U.S. and Iran stepped up attacks across the Gulf, with shipping threatened by a ‌potential Red Sea closure on top of the restricted traffic through the Strait of Hormuz.

Brent ‌crude futures rose by $3.98, or 4.73%, to $88.21 a barrel by 2:16 p.m. ET (1816 GMT). U.S. West Texas Intermediate futures were up $3.80, or ​4.81%, at $82.75.

For the week, both benchmarks were headed for a 16% increase, with Brent on track for a third consecutive weekly gain and WTI set for its second.

Diesel refining margins reached record highs on Friday, with low-sulphur gasoil futures touching $66.25 over Brent crude.

The Middle East is a major diesel exporter and the Hormuz closure, as ‌well as attacks on oil refineries, ⁠have tightened fuel markets and bolstered prices globally.

The collapsed truce between the U.S. and Iran has resulted in a sharp decline in oil flows in the strait as ⁠Iran targets vessels transiting through it. Before the Iran war, about 20% of global oil supplies flowed through the waterway.

The two foes expanded fighting on Friday, with the U.S. striking bridges and an airport in Iran and Tehran ​hitting a ​power and desalination plant in Kuwait. Iran said it ​launched more strikes on U.S. facilities in ‌the Middle East, including the first direct attack in Syria, after a sixth straight night of U.S. strikes on Iranian military facilities.

Iran has pressed the Houthis to close the Red Sea route if the U.S. attacks Iran’s power infrastructure.

“Given that so much of Saudi Arabia’s exports have been redirected to the port of Yanbu via the East-West Pipeline to avoid Hormuz, any such development is a threat indeed,” Tamas Varga, analyst ‌at PVM Oil Associates, wrote in a note.

Saudi Arabia has ​diverted more than 70% of its normal daily crude exports to ​the Red Sea port of Yanbu since ​the beginning of the war. Shipments from Yanbu averaged 4 million barrels per day ‌in recent weeks, up from around 973,000 ​bpd in the same period ​last year.

Qatar’s defence ministry said its armed forces thwarted an Iranian missile attack early on Friday and the interior ministry said a child was wounded by shrapnel resulting from interception operations.

In a ​different conflict zone, Ukraine’s military said ‌it struck a Russian oil refinery in the Yaroslavl region on Thursday.

(Reporting by Nicole Jao ​in New York, Robert Harvey in London, Mohi Narayan in New Delhi and Helen Clark ​in PerthEditing by David Goodman, Philippa Fletcher, Rod Nickel)