NEW YORK (Reuters) - U.S. stocks closed higher and Treasury yields rose on Wednesday after the release of written testimony from ex-FBI chief James Comey, with investors looking ahead to his U.S. Senate appearance on Thursday, the same day as a British parliamentary vote and a European Central Bank meeting.

Traders work on the floor of the New York Stock Exchange (NYSE) in New York City, U.S., May 31, 2017. REUTERS/Brendan McDermid

A smoothly executed rescue of Spain’s Banco Popular lifted bank stocks in Europe, while oil prices suffered a steep slide after the U.S. government reported an unexpected increase in crude and gasoline inventories. [nL3N1J415K]

U.S. crude CLcv1 fell 5.08 percent to $45.74 per barrel and Brent LCOcv1 was last at $48.12, down 3.99 percent on the day.

The Dow Jones Industrial Average .DJI rose 37.46 points, or 0.18 percent, to end at 21,173.69, the S&P 500 .SPX gained 3.81 points, or 0.16 percent, to 2,433.14 and the Nasdaq Composite .IXIC added 22.32 points, or 0.36 percent, to 6,297.38.

In a written statement posted on the web on Wednesday, Comey, the former FBI chief fired by President Donald Trump, said Trump asked him to back off from a probe into former national security advisor Michael Flynn and told Comey, “I need loyalty. I expect loyalty.”

Comey is to testify before Senators on Thursday.

Treasury prices slid after his comments were released, sending benchmark 30-, 10- and 2-year yields US30YT=RRUS10YT=RRUS2YT=RR to session highs.

“The market was pricing in a much worse news flow from the Comey testimony than what we saw,” said Bruno Braizinha, interest rates strategist at TD Securities in New York.

“But it’s one risk out of the way, and now the market is looking at the ECB meeting and the UK election,” he added.

Slideshow ( 2 images )

Comey’s Senate appearance, Britain’s national election and the ECB meeting are what ING currency strategist Viraj Patel said had been dubbed ‘Triple Threat Thursday,’ which he said could be “an event-filled day that could send global markets on a bumpy ride.”

The lead of British Prime Minister Theresa May’s Conservative Party over the opposition Labour Party has halved to five percentage points, according to a Kantar poll published on Wednesday.

The euro EUR= turned shaky after reports suggested the ECB would lower its inflation targets. It was last down 0.11 percent to $1.1260.

“Maybe tomorrow’s ECB meeting sees nothing but platitudes and disappoints a market that is getting ahead of itself,” said Societe Generale analyst Kit Juckes.

“But (for us) that would be a huge euro buying opportunity, because ECB normalization is coming. And when it does, the euro simply won’t be able to sustain undervalued levels for long.”

In Europe, banking shares .SX7E closed up 0.87 percent.

Struggling Banco Popular was absorbed by Spain's biggest bank Santander SAN.MC for a nominal 1 euro, the first use of a regime to deal with failing banks adopted after the 2008 financial crisis.

The success of the process pushed shares in many major banks higher, supporting a recovery for Madrid's stock market .IBEX that lost steam later in the day.

“The market has taken Banco Popular as positive news because essentially this is not a bankruptcy but a sort of rescue, even if its subordinated bondholders have been sharply hit,” said Giuseppe Sersale, a fund manager at Anthilia Capital in Milan.

The pan-European FTSEurofirst 300 index .FTEU3 lost 0.08 percent and MSCI's gauge of stocks across the globe .MIWD00000PUS gained 0.04 percent.

(To view a graphic on 'World FX rates in 2017' click tmsnrt.rs/2egbfVh)

(To view a graphic on 'Global bonds dashboard' tmsnrt.rs/2fPTds0)

(To view a graphic on 'Global market cap' reut.rs/2mcp7T1)

(To view a graphic on 'Emerging markets in 2017' tmsnrt.rs/2ihRugV)