U.S. stocks closed broadly higher on Wednesday after the midterm election results came in about as expected, lifting a cloud of uncertainty that was weighing on the market.

The major averages hit their session highs after President Donald Trump indicated he is willing to work with Democrats on policy initiatives that would help the economy keep growing.

The Dow Jones Industrial Average closed up 545 points, led by gains in UnitedHealth and Apple. The gained 2.1 percent as the health care, tech and consumer discretionary sectors each rallied more than 2.8 percent. The Nasdaq Composite rose 2.6 percent.

Wednesday's post-midterms rally was larger than the average gain that follows the contests. Goldman Sachs noted the S&P 500 has averaged a gain of 0.7 percent from the day before the elections to the day after midterms. Wednesday marked the biggest post-midterms gain for both the Dow and S&P 500 since the day after the 1982 contests, when the indexes surged 4.3 percent and 3.9 percent, respectively.

"Hopefully we can all work together next year to continue delivering for the American people, including on economic growth, infrastructure, trade, lowering the cost of prescription drugs," Trump said in a news conference. "The Democrats will come to us with a plan for infrastructure, a plan for healthcare, a plan for whatever they're looking at and we'll negotiate."

Democrats won control of the House of Representatives while Republicans retained their hold on the Senate, as the midterm's outcome split Congress.

"We believe (out of consensus) that a split Congress is the best outcome for US and global equity markets," said Marko Kolanovic, a widely followed quantitative analyst at J.P. Morgan, in a note. "As the President cannot count on Congress or the Fed for more easing, he will need to do what is in his power to keep the economy rolling – drop the damaging trade war and turn it into a winning deal."