Sen. Doug Jones (D-Ala.) won a special election in December, trimming the Republican majority in the Senate. (AP)

Two affiliated Democratic groups trying to help their party win back the Senate majority raised $31.8 million in 2017, the organizations said, a record haul for an off-election year that edged out a cluster of similar organizations on the Republican side. But the amount still left them at a cash disadvantage headed into 2018.

Senate Majority PAC, the top super PAC aligned with Senate Democrats, raised $21.7 million last year, the group told The Washington Post. Most of that total — about $17.2 million — came during the second half of the year.

Majority Forward, an affiliated nonprofit, brought in $10.1 million last year. Together, the two groups started 2018 with about $19.5 million in their accounts, $13.6 million for Senate Majority PAC and $5.9 million for Majority Forward.

On the Republican side, the Senate Leadership Fund, One Nation and two other organizations together raised $31.6 million in 2017 and started this year with $23.9 million in the bank.

Democrats are facing a difficult midterm election map, defending 26 seats including 10 in states President Trump won. Republicans, who hold a 51-49 majority in the Senate, are only defending eight seats.

But Trump’s unpopularity and the struggles historically experienced by a president’s party in his first midterm election have instilled confidence in Democrats during the past year that they have a chance to compete for control of the upper chamber.

“As the election of Senator Doug Jones in Alabama showed, Democrats across the country are enthusiastic to get back to the polls and hold President Trump and Leader McConnell accountable,” J.B. Poersch, the president of Senate Majority PAC and Majority Forward, said in a statement.

Poersch was referring to the special election last year in which Jones defeated embattled Republican Roy Moore, giving Democrats a surprise win in a state that has long been in Republican hands.

Senate Majority PAC spent more than $3 million through a group called “Highway 31” to help Jones win, federal campaign finance filings show. The group was named for the road connecting Alabama’s four major cities.

Late last year, Highway 31 declined to publicly disclose its donors, the largest of which was Senate Majority PAC.