Pete Buttigieg (L) and Joe Biden exchange words during a break in the second Democratic debate hosted by NBC News in Miami, June 27, 2019.

Pete Buttigieg and Joe Biden led the 2020 Democratic primary field in second-quarter fundraising, while the leading candidates entered July with a healthy store of cash, according to new campaign filings.

Buttigieg hauled in $24.9 million from April through June, the best in the field of about two dozen candidates. Biden took in the second most with about $22 million, followed by Sens. Elizabeth Warren and Bernie Sanders with about $19.2 and $18 million in contributions, respectively.

For the fundraising totals, CNBC tracked individual contributions, a key way to gauge support for candidates. The exception is former Rep. John Delaney, the only candidate to self fund the vast majority of his campaign operation.

Sanders entered July with a $27.3 million war chest, the biggest among Democratic candidates. Buttigieg, the mayor of South Bend, Indiana, had $22.7 million on hand, while Warren had $19.8 million.

The numbers, filed late Monday, give a glimpse into who has the resources to build infrastructure in key early nominating states — and who may struggle just to stay in the race in the coming months. The figures also offer clues about who may be able to keep up with President Donald Trump's campaign, which has a head start on the fractured Democratic field and entered July with $56.7 million in the bank.

The candidates are jockeying for position ahead of the first primary nominating contests in February. Biden, the former vice president, has led the vast majority of early national and state polls, typically followed by a combination of Sanders, Warren, Sen. Kamala Harris and Buttigieg.

A handful of candidates burned through cash faster than they raised it in the second quarter. They include former Rep. Beto O'Rourke and Sens. Kirsten Gillibrand, Cory Booker and Amy Klobuchar.

Miramar, Florida, Mayor Wayne Messam had about $31,000 in cash left at the end of June, the least in the field. (He spent only about $23,000 in the second quarter, less than half of what he raised). Rep. Tim Ryan of Ohio had about $335,000 left in the bank, while author Marianne Williamson and Rep. Seth Moulton of Massachusetts went into July with about $550,000 and $725,000 on hand, respectively.

Subscribe to CNBC on YouTube.