Sen. Bernie Sanders drastically ramped up his campaign's spending in January as the Democratic primary contest engaged, racing through nearly $35 million as he worked to try to match the infrastructure that former secretary of state Hillary Clinton built over the course of last year.

As a result, even though he outraised her for the first time, Clinton expanded her cash lead by the end of the month. After spending $21.2 million in January, Clinton ended the month with nearly $33 million in the bank. Sanders had almost $14.7 million.

A huge share of Sanders's spending in January — $14 million — went into television ads, outpacing the $10 million that Clinton put into advertising. That helped him get more commercials on the air in Nevada in the run-up to Saturday's caucuses, which Clinton won. Sanders had aired 4,650 spots in the state since January, compared to Clinton's 4,156, according to Kantar Media/CMAG data analyzed by the Wesleyan Media Project.

Clinton still spent more on payroll last month, shelling out $4 million for hundreds of staffers the campaign has brought on. But Sanders more than doubled his spending on payroll compared to last quarter, plowing $2.5 million into staff, up from less than $1 million he was paying monthly at the end of last year.

Anu Narayanswamy contributed to this report.