Senate candidate Rep. Beto O’Rourke (D-Tex.) arrives for a campaign rally at Texas Southern University in Houston on Oct. 9. (Loren Elliott/Reuters)

Democratic candidates in some of the most heated Senate and House contests saw a surge of donations to their campaigns in the final stretch before the midterm election — a sign of heightened energy among Democrats eager to boost candidates over the finish line in their hopes of regaining the majority in Congress.

The donations to Senate Democrats offer a glimmer of hope in their largely defensive fight in the upper chamber. Democratic Senate candidates in the nine most competitive races, including incumbents in states that voted overwhelmingly for President Trump, raised a total of $212 million. Republicans, by contrast, raised $164 million in the same contests, according to Federal Election Commission records filed Monday night.

Democrats in those contests have so far outraised Republicans in the cycle. The majority of them also outperformed their GOP opponents in the third quarter, from July through September, records show.

House Democratic candidates also received a surge of cash in the third quarter. In many of the most competitive House races across the country, the Democratic challenger outraised the Republican incumbent in the three-month period — some raising more than twice the amount the GOP incumbent raked in.

The surge in direct contributions to the House campaigns shows that the enthusiasm for Democratic challengers in 2018 gained steam this fall — especially from those giving contributions of $200 or less.

The donations to campaign committees flowed in as outside groups stepped up support for both sides with big-money donations from wealthy contributors.

Wealthy donors gave dozens of millions in September alone to outside groups to support GOP candidates, many with the goal of helping Republicans retain control of the House. Notably, mega-donors Sheldon and Miriam Adelson spent $32 million in September to help Republicans, bringing their total contributions to GOP super PACs this cycle to at least $87 million.

Big money is helping the left as well. Senate Majority PAC, a super PAC that works to elect Democrats to the Senate, has outraised its GOP counterpart so far in the cycle.

On the Senate side, the top fundraiser in the third quarter was Rep. Beto O’Rourke (D-Tex.), who shattered previous Senate fundraising records with $38.1 million raised in the third quarter, compared with $11.6 million for GOP incumbent Sen. Ted Cruz.

While Cruz is leading in public polling, O’Rourke has amassed a major following in and out of Texas in recent months. O’Rourke’s rally featuring country music star Willie Nelson in September drew a crowd of roughly 50,000, according to his campaign.

President Trump announced Monday that he will hold a “Make America Great Again” rally in Houston on Oct. 22 to support Cruz. Trump had promised to hold a “major rally” for Cruz in “the biggest stadium in Texas we can find.” The rally venue announced Monday has a maximum capacity of about 10,000.

O’Rourke’s campaign raised about 45 percent of its money from donors giving $200 or less, which is typically viewed as a sign of grass-roots energy. But as much as 46 percent of the campaign’s larger contributions in the third quarter came from outside Texas — indicative of his growing national profile but also an opening for Cruz to accuse him of drawing his support from out of state.

Cruz has raised 30 percent of his donations in smaller contributions, and collected two-thirds of his larger donations in the third quarter from out of state — perhaps not surprising considering he is a well-established national figure.

Democrats running for the Senate collected a large percentage of their campaign cash from low-dollar donations — a trend among Democratic campaigns this fall, fueled by anti-Trump sentiment.

In the Florida Senate race, Democratic incumbent Bill Nelson raised about 22 percent of his campaign cash this cycle in small donations. By comparison, less than 3 percent of the campaign donations of his opponent, Gov. Rick Scott (R), came from such donations. Scott personally gave his campaign $39 million, which makes up the majority of his campaign funds.

An outlier was in Arizona, where Rep. Martha McSally (R) is vying for the seat being vacated by Sen. Jeff Flake (R). About one-quarter of McSally’s donations were less than $200, compared with about one-fifth for her opponent, Rep. Kyrsten Sinema. Sinema raised more money overall, however, with $16 million compared with McSally’s $12.6 million.

In Missouri, Democratic incumbent Claire McCaskill is locked in a tight race against her opponent, Josh Hawley. McCaskill spent a large chunk of the $30 million she raised this cycle, leaving her with just $3.1 million in the bank for the final month of the campaign. Her opponent raised $13.9 million but had slightly more cash on hand, with $3.5 million.

Among Democratic challengers in competitive races who raked in massive amounts of cash over the GOP incumbents were candidates who raised upward of $6 million to $7 million in just three months — such as Katie Hill in California’s 25th Congressional District and Antonio Delgado in New York’s 19th District.

Another standout fundraiser among the House Democrats is Amy McGrath, running in the 6th District in Kentucky, which covers Lexington and Frankfort. After burning through her cash during a tough primary, McGrath raised money at a faster clip than GOP incumbent Rep. Garland “Andy” Barr for her general election run in one of the most competitive House races in the country.

McGrath raised $3.6 million, compared with Barr’s $1.2 million this quarter. For the cycle, they each raised $6.7 million. Some $1.6 million of McGrath’s total haul — about one-quarter — came from small-dollar donations.