The Dow Jones Industrial Average posted its biggest weekly gain since 1938, paring some of the losses of recent weeks, as lawmakers agreed to the largest economic-relief package in U.S. history in response to the coronavirus pandemic.

Investors have been on a roller-coaster ride as attempts to curb the coronavirus pandemic constrain economic activity and policy makers work to cushion the blow. Major U.S. stock indexes posted double-digit gains for the week—with the Dow surging 13% and the S&P 500 climbing 10%—but remain down...