U.S. stocks maintained solid gains Wednesday afternoon as Wall Street weighed a surprising victory by Republican Donald Trump in the presidential election.

The S&P 500 rose 1.3%, the Dow Jones Industrial Average gained 1.6% and the Nasdaq rose 1.1%.

European stocks traded higher following losses earlier in the trading session.

Trump, who will serve as the 45th president of the United States, surprisingly won New Hampshire, North Carolina, Florida, and Wisconsin, key battleground states both candidates needed to secure to win the election.

Prior to the election, markets were factoring in a win by Democratic nominee Hillary Clinton, who said in her concession speech Wednesday that "we must accept this result and then look to the future. Donald Trump is going to be our president. We owe him an open mind and the chance to lead." President Obama spoke today, saying he and his team will work with Trump on a smooth transition of power. 

The election saw Senate and House Republicans maintain their majorities in Congress.

"We think the stock market selloff will be short lived," Deutsche Bank analysts wrote in a note prior to the markets opening on Wednesday. "This apparent Republican sweep is positive for the broad market and especially health care stocks. The only sector that might suffer from this election outcome is energy, as we think a greater U.S. oil supply outlook weighs on the oil price recovery."

The energy sector was higher Wednesday after seeing losses earlier in the session. The Energy Select Sector SPDR ETF (XLE) was up 2%. But SunPower (SPWR) fell 14.2% as investors believe Trump's focus on coal and oil is seen as a negative for the global energy company.

Domestic crude oil supplies increased by 2.4 million barrels in the week ended Nov. 4, according to the U.S. Energy Information Administration. West Texas Intermediate crude oil settled 0.6% higher to $45.27 a barrel.

Health care stocks were rising Wednesday in reaction to Trump's victory. Biotech stocks, including Gilead Sciences (GILD) , Celgene (CELG) and Biogen (BIIB) were higher as was the iShares Nasdaq Biotechnology exchange-traded fund (IBB) that tracks these stocks. The ETF rose 8.7% in trading Wednesday. Drugmaker Pfizer (PFE) was up 8.6%.

A Hillary Clinton victory and a Democratic takeover of Congress would have been the worst-case scenario for biotech and drug stocks given her relentless criticism of rising drug costs and promises to curb them. Trump hasn't been as vocal or openly hostile to drug companies, but he hasn't embraced or even defended their pricing practices, either, wrote TheStreet's Adam Feuerstein.

Financial stocks saw a jump as Bank of America (BAC) shares rose 5.7%, Wells Fargo (WFC) gained 6%, and JPMorgan Chase (JPM) shares bounced higher by 5.7%. The SPDR Financial Sector exchange-traded fund (XLF) that tracks the financial-services sector was up 4.4% Wednesday.

"The re-pricing of everything has already begun," Stephen Guilfoyle, Stuart Frankel's chief market economist, wrote in a note. "Donald Trump has some isolationist ideas, but is not as anti-trade as presented in the media. His administration will likely be pro-business. His economics are pro-growth in the short-term. Reduced taxes, and increased fiscal spending provided by increased borrowing should produce a higher GDP."

Health care insurers were mixed as they prepared for a possible repeal of the Affordable Care Act under a Trump presidency. While Trump hasn't said what he will replace the health care law with, UnitedHealth   (UHN)  fell 0.6% Wednesday, while competitors Anthem (ANTM) , Cigna (CI) , Humana (HUM)  and Aetna  (AET)   saw gains. TheStreet's Alicia McElhaney has more analysis

Investors will be assessing the Federal Reserve's next move to determine whether the U.S. central bank will raise interest rates at its December meeting as the U.S. economy has strengthened. An economist told the Associated Press that Trump's victory rules out a rate hike entirely.

"Given the adverse market reaction we have already seen, the Fed's planned December rate hike is now off the table," Paul Ashworth, chief U.S. economist at Capital Economics, told the AP. He said Fed Chair Janet Yellen and other top policymakers might even resign in the event of a Trump presidency, because his victory demonstrates that that many Americans share his view that the Fed has been "overtly political."

Safe-haven assets such as gold and government bonds moved higher on Wednesday as appetite for riskier assets fell. 

Gold prices settled lower at $1,273.50 an ounce, down less than 0.1%. Gold had risen to above $1,300 an ounce after it became clear Trump would win the U.S. presidency. U.S. Treasury bond yields, which move in the opposite direction of their price, jumped to 2.068% for the first time since January.

Gold mining stocks jumped, including Newmont (NEM) up 1.4% and Goldcorp (GG) up 0.5% paring some of their earlier gains. 

The Mexican peso fell at one point early Wednesday by more than 12% against the U.S. dollar. Throughout this election season, the peso has fallen when Trump's chances have risen as investors worried over the state of trade relations between the two countries under a Trump administration. Trump has promised to build a wall between the U.S. and Mexico.

United States Steel (X)  gained 17.8% to $24.68 in afternoon trading as Jefferies analysts wrote that "the U.S. steel industry should stand out as a unique beneficiary of a Trump presidency." Analysts upgraded their rating of U.S. Steel to a buy, saying that "increased infrastructure spend may significantly boost demand for long steel product." They also highlighted that the U.S. "is already short steel, and falling imports will improve domestic pricing power."

Corrections Corporation of America (CXW) jumped 46.2% as investors anticipated the usage of prisons will increase with Trump's promise to deport illegal immigrants.

Viacom (VIAB) reported adjusted quarterly earnings of 69 cents a share, topping analysts' estimates by 3 cents. Revenue of $3.23 billion came in below forecasts.

Viacom investors will be looking for any commentary on a possible merger to reunite with CBS (CBS) . Viacom shares increased 1.6% Wednesday.

Wendy's (WEN) shares were up about 1.9% after the fast-food chain beat earnings estimates on revenue of $364 million.

Mylan (MYL) , the maker of the allergic reaction emergency treatment, EpiPen, is scheduled to report earnings after the market closes, as is Shake Shack (SHAK) .

More from Markets

Apple and GE Switch Roles; Musk's Super Control of Tesla Explained -- ICYMI

Apple and GE Switch Roles; Musk's Super Control of Tesla Explained -- ICYMI

Trump May Be More to Blame For Higher Oil Prices Than OPEC

Trump May Be More to Blame For Higher Oil Prices Than OPEC

Dow Falls Over 200 Points as Apple's Slump Offsets Gains in General Electric

Dow Falls Over 200 Points as Apple's Slump Offsets Gains in General Electric

Week Ahead: Major Earnings on Tap as Wall Street Readies for Geopolitical Moves

Week Ahead: Major Earnings on Tap as Wall Street Readies for Geopolitical Moves

3 Hot Reads From TheStreet's Top Premium Columnists

3 Hot Reads From TheStreet's Top Premium Columnists