U.S. stocks charged to fresh highs Wednesday, with major indexes logging their biggest one-day rally since the election.

Stocks had been under pressure in early trading as a decline in health-care and biotechnology stocks weighed on broader indexes. But a broad afternoon rally lifted the Dow Jones Industrial Average nearly 300 points and elevated both the blue-chip index and S&P 500 to closing records.

The...