By Joe Wallace and Karen Langley

A climb in shares of Pfizer boosted the Dow Jones Industrial Average Wednesday after the US. government agreed to pay the drugmaker and partner BioNTech to secure doses of their experimental Covid-19 vaccine.

The blue-chip index gained 0.6%, or about 150 points. The S&P 500 added 0.5%, while the Nasdaq Composite edged up 0.1%.

Pfizer shares rose 5.2%, leading the Dow. Under the $1.95 billion agreement, the U.S. will receive 100 million doses of the vaccine, after it is cleared by regulators, and can also acquire another 500 million doses. The vaccine is set to enter late-stage testing this month.

Investors have welcomed any signs of progress toward a vaccine that could allow economic activity to resume without a subsequent rise in infections. Drugmakers stand poised to benefit: The U.S. also has vaccine deals with other companies including AstraZeneca.

"The experts were telling us, back in February, March and April, it's going to be five years before we see a vaccine, and here we are with some possible good news on vaccine that's going to hit this year," said Phil Orlando, chief equity market strategist at Federated Hermes. "I think the market is taking that very favorably."

Corporate earnings remained a key focus for investors Wednesday, with some of the technology companies that have driven much of the stock market's recovery since March due to report quarterly results. Investors will get fresh cues about the outlook for the sector when Microsoft, whose shares have risen 34% in 2020, reports results for its fourth quarter after the close of trading.

"For Microsoft, expectations are probably quite high," said Hani Redha, a portfolio manager at PineBridge Investments. "There will be some sense of how well cloud [computing] in particular has fared."

Tesla is also due to release earnings Wednesday. The electric-vehicle maker's shares have soared in recent months, in part on increased expectations that it will report a fourth straight quarterly profit. That could qualify Tesla for inclusion in the S&P 500.

Shares in Snap dropped 6% after the company reported slowing revenue growth for the second quarter. Shares in Spotify Technology rose 4.6% after The Wall Street Journal reported that the streaming company had reached a new licensing agreement with Vivendi's Universal Music Group.

HCA Healthcare's shares gained 11% after the company reported higher profit in the second quarter.

"In general, the low bar, or at least the lower expectations going into Q2 -- actual earnings reports have been beating that hurdle, so perhaps that's been also adding to the momentum or the optimism that we're seeing in the markets," said Amy Kong, chief investment officer at Barrett Asset Management.

Wednesday's moves came after China's Foreign Ministry said the U.S. had instructed China to close its consulate in Houston. That raised the specter of an escalation in tensions between the world's two largest economies and prompted Beijing to condemn the move as outrageous and unprecedented.

The rising tension weighed on markets overseas. The regional Stoxx Europe 600 index fell 0.9%. Hong Kong's flagship Hang Seng Index dropped 2.3%.

Among investors' concerns: Senate Majority Leader Mitch McConnell said Tuesday that Congress is unlikely to pass a new fiscal stimulus bill quickly. The White House and Senate Republicans are struggling to bridge divisions on a payroll-tax cut, school funding and other issues.

"We are cautiously optimistic that they will reach a decision and will send money prudently but appropriately to allow the economy to continue to recover back toward some semblance of normalcy," said Nancy Prial, co-CEO and senior portfolio manager at Essex Investment Management.

The yield on the benchmark 10-year Treasury note slipped to 0.595% -- its lowest close since April 24 -- from 0.606% Tuesday, according to Tradeweb. Yields fall as bond prices rise.

--Xie Yu contributed to this article.

Write to Joe Wallace at Joe.Wallace@wsj.com and Karen Langley at karen.langley@wsj.com