Global stocks capped off a week of strong gains as two key uncertainties weighing on markets edged toward a resolution.

Major indexes and government bond yields recorded big swings in early trading Friday as investors awaited details on a trade deal between the U.S. and China. Encouraging developments on a truce, along with some clarity on Brexit, spurred an early rally in global stocks.

The progress is huge. No question about it, said Chris OKeefe, a lead portfolio manager at Logan Capital.

The S&P 500 added 0.7% for the week, while the tech-heavy Nasdaq Composite rose 0.9%. Both indexes closed at records Friday. The Dow Jones Industrial Average climbed 0.4% for the week, ending 0.1% below its highest-ever level from Nov. 27.

Stocks in Asia and Europe have also climbed in recent sessions, continuing a banner year for stocks around the world.

Tweets from President Trump and other trade headlines have driven wild moves across stock, bond and currency markets this year. The trade battle injected unease into a market that was already roiled at times by the path of Federal Reserve interest rate policy and fears that a decadelong economic expansion could wither. Many investors were eagerly awaiting a pact because the dispute had the potential to weigh on global growth and crimp corporate investment.

Although U.S. stocks finished the week higher, major indexes barely budged on the last trading day of the week as some of the initial optimism from Thursday and early Friday waned and investors reviewed the sparse details of the deal. The S&P 500 and Dow both inched up less than 0.1% Friday.

Its a classic case of sell-the-news, said R.J. Grant, director of equity trading at KBW. Weve been rallying, rallying, rallying waiting for it.

Mr. Grant said some facets of the deal still appeared ambiguous. Even before Fridays announcement, enthusiasm surrounding a trade deal has helped U.S. stocks record an exceptional year, with the S&P 500 up 26% and on pace for its best annual performance in years.

The rally has also been underpinned by the Federal Reserve, which has cut interest rates three times this year to shore up growth. Earlier this week, the central bank kept rates steady and showed no appetite to raise them in the near term as it sounded an upbeat note about the economy.

Other global markets got a boost Friday after a resounding election victory for Prime Minister Boris Johnsons Conservative Party. He has pledged to move quickly to take Britain out of the European Union. The pan-continental Stoxx Europe 600 climbed 1.1%.

The geopolitical risks thought to be strangling world economic growth, incredibly, just in the last 24 hours, seem to be closer to getting resolved in a big, big way, said Chris Rupkey, chief financial economist at MUFG. The outlook in 2020 looks better than it has in months.

Mr. Rupkey said he expects stocks around the world to keep rallying and bond yields to rise further.

The Stoxx Europe 600 has risen 22% this year, while indexes in mainland China and Japan are up by double-digit percentages.

In the U.K., the FTSE 250 gauge, which tracks companies with a significant domestic focus, rose 3.4% on Friday to a record. Mr. Johnson has promised to deliver billions of pounds in public spending to help working-class voters still hurting from the financial crisis.

These results really make the U.K. equity markets investible again, said Sue Noffke, head of U.K. equities at Schroders. Greater political clarity and less uncertainty really does reduce the level of risk for investors. In particular, international investors.

The pound declined 0.4% against the dollar Friday, after advancing more than 2% late Thursday as exit polls showed Mr. Johnson would capture a clear majority.

The U.K. election results — from a risk-appetite point of view — has been the cherry on the cake, said Andrea Iannelli, investment director, fixed income at Fidelity International.

A wait-and-see approach from the European Central Bank on changing interest rates, the Federal Reserves cuts to keep the U.S. economy growing, a recent stabilization in economic outlook and the suggestion of a long-awaited trade deal has made for a bullish Christmas for markets, Mr. Iannelli said.

In Asia, Japans Nikkei 225 index jumped 2.6% to close at the highest level this year. The Shanghai Composite Index rose 1.8%, capping off a second straight week of gains.

To be sure, previous breakthroughs in both trade and Brexit have proved to be false dawns. Trade tensions have dragged on for almost two years, and Mr. Johnson still faces the challenge of securing a long-term trade deal with the EU.

This lingering uncertainty incited demand for haven assets. Gold prices recorded the biggest weekly gain since August. Investors also bought government bonds, sending the yield on the 10-year Treasury note to 1.820% Friday, from 1.901% Thursday. Yields fall as bond prices rise.

This weeks rise was led by the technology sector, while real estate segment was the weakest performer in the S&P 500.

Next week investors will turn their attention to economic data on the domestic consumer and inflation. Figures on Friday showed that retail sales grew at a lackluster pace in November ahead of the critical holiday shopping season.

Write to Gunjan Banerji at Gunjan. and Steven Russolillo at steven.

Dow, S&P Finish Record-Filled Week With Gains

: S&P 500, Dow eke out records; Nasdaq win streak ends

Oil hits three-month high on falling oil stocks, investor optimism

Oil hits three-month high on falling oil stocks, investor optimism

Oil hits three-month high on falling oil stocks, investor optimism

: Amgen Tasks Its Labs With Finding New Blockbusters

: EASYJET : Sixteen flights cancelled at Lisbon Airport due to three-day strike

: As Shale Wells Age, Gap Between Forecasts and Performance Grows

Egypt awards oil and gas exploration concessions in Red Sea – statement

: Smiths Group chief likely to step down next year – report

Michaels : Cos. Shares Trading Higher as New President, CEO Named

Pivotal Software Shareholders Approve Acquisition by VMware

China Tries a Shot of Liquor to Cure Ailing Province

Uniqlo founder Yanai resigns as SoftBank board member after 18 years

Intesa Sanpaolo : Appoints Five New Top Managers