Sen. Bernie Sanders talks to senior strategist Tad Devine at the Van Dam diner this month in New York. (Mary Altaffer/AP)

The small-dollar fundraising juggernaut that has kept Bernie Sanders’s insurgent White House bid afloat far longer than anticipated has generated another unexpected impact: a financial windfall for his team of Washington consultants.

By the end of March, the self-described democratic socialist senator from Vermont had spent nearly $166 million on his campaign — more than any other 2016 presidential contender, including rival Hillary Clinton. More than $91 million went to a small group of admakers and media buyers who produced a swarm of commercials and placed them on television, radio and online, according to a Washington Post analysis of Federal Election Commission reports.

While the vast majority of that money was passed along to television stations and websites to pay for the advertising, millions in fees were kept by the companies, The Post calculated. While it is impossible to determine precisely how much the top consultants have earned, FEC filings indicate the top three media firms have reaped payments of seven figures.

Sanders’s money blitz, fueled by a $27 average donation that he repeatedly touts, has improbably made the anti-billionaire populist the biggest spender so far in the election cycle. The campaign’s wealth has been a surprising boon for vendors across the country who signed on to his long-shot bid.

The large profits stem in part from the fact that no one in Sanders’s campaign imagined he would generate such enormous financial support. So unlike Clinton, he did not cap how much his consultants could earn in commissions from what was expected to be a bare-bones operation, according to campaign officials.

That has meant big payouts for the firm of senior strategist Tad Devine, which has produced the bulk of the campaign’s ads; Old Towne Media, a small media placement operation run by two of Devine’s longtime buyers; and Revolution Messaging, a digital firm led by veterans of President Obama’s 2008 campaign.

And the commissions may continue to pile up, even though Sanders’s chances of securing the Democratic nomination have been all but extinguished. After he lost four out of the five states that held primaries Tuesday, his campaign began laying off 225 staffers around the country. But Sanders is still actively seeking donations, and he has said repeatedly that he plans to press on through the California primary in early June, an effort that could include more expensive advertising. “So long as we have a path toward victory, no matter how narrow it may be, we’ll pursue it,” the senator told The Post on Wednesday.

In an interview, Devine acknowledged that he has made more money than expected from the campaign, but he noted that he is working for a much lower rate than usual. While he usually gets a double-digit percentage of a campaign’s ad spending, the veteran admaker is instead splitting a single-digit-percentage commission with the media buyers at Old Towne Media.

Because of his commitment to Sanders, Devine said he had to turn down doing campaigns this year for two previous foreign clients, the kind of consulting that had taken up most of his time in recent years. (His work for a Bolivian presidential candidate was featured in the 2005 documentary “Our Brand is Crisis,” which inspired a feature film of the same name last year starring Sandra Bullock.)

“Yes, there was more profit from this account than I thought there would be at the beginning, but there’s also the fact that I can’t do work I could be doing elsewhere,” Devine said.

When he signed on in 2014 with Sanders, a longtime client and friend of two decades, Devine said he never envisioned the campaign would end up being a behemoth.

“It didn’t seem like a realistic possibility that there would be an endeavor of this nature,” he said.

The huge sums that Sanders has been able to command show how lucrative it can be to harness a large, energized base of small donors online — and how overwhelming it can be to manage a sudden flood of cash. By the end of March, 2.2 million supporters had contributed more than $184 million to Sanders’s campaign — just about $7 million less than Clinton raised in the same time period. More than half his money has come from donors who have contributed $200 or less, according to the nonpartisan Campaign Finance Institute.

As donations surged this year, the Sanders campaign ratcheted up its spending each month, racing through an astounding $45 million in March alone.

Behind the scenes, aides scrambled to handle the influx of cash, boosting the campaign’s investments in polling, field organizers and direct mail. But the bulk of the newfound resources went into paid ads, most of them produced by Devine, a longtime Democratic media strategist who served in senior roles on the presidential campaigns of Al Gore and John F. Kerry.

The Clinton campaign, which went on the air two months earlier than Sanders, has still spent far less on media buys and consulting: nearly $62 million compared with his more than $91 million. (Clinton’s total does not include money spent through a joint fundraising committee with the Democratic Party.)

Sanders said in an interview Wednesday that the campaign has relied heavily on television as a counterweight to the establishment support that Clinton enjoys in many states.

“Television is one way where we can have an equal opportunity, in some cases more,” the senator said. “So we use it.”

A campaign spokesman declined to comment on whether Sanders feels the high fees earned by his media consultants are appropriate.

The outfit placing the television and radio spots on the air, Old Towne Media, is run by two veteran Democratic media buyers, Barbara Abar Bougie and Shelli Hutton, who have worked with Devine for decades and handled ad placement for Sanders’s previous campaigns.

As of the end of March, Old Towne Media had placed nearly $60 million worth of commercials on local television and radio stations, according to ad tracking data obtained by The Post. Such volume translates into significant fees, even with a single-digit commission split between the media buyers and Devine’s firm, Devine Mulvey Longabaugh. A small fee of just 5 percent, for example, would equal almost $3 million. (Ad buyers alone typically get between 2 percent and 5 percent commission.)

Abar Bougie declined to comment, and Hutton did not return a request for comment.

On top of Devine’s commission, which is paid out of funds sent to Old Towne Media, Devine Mulvey Longabaugh has received more than $4 million for media production from the Sanders campaign, FEC reports show. A share of that money was used to pay licensing fees for images and music.

Devine noted that his firm has produced a dizzying number of spots: more than 250 television, radio and digital ads altogether.

“It has been a much bigger enterprise than I expected, and as a result, I have had to build a much bigger apparatus,” he said, adding: “I’m very proud of the work we’ve done.”

Another large share of the campaign’s spending — more than $23 million — has gone to Revolution Messaging, a 60-person digital firm founded by Scott Goodstein, who served as Obama’s external online director in 2008.

The company, whose work has helped raise more than $200 million for the campaign, provides an array of services, including digital consulting, online ads and website development. In return, Revolution gets a monthly $30,000 retainer, along with a 10 percent commission on digital media buys, according to a person close to the campaign who spoke on the condition of anonymity to describe contractual details. That translates to at least $2 million in fees so far, according to an analysis of FEC filings. The firm declined to comment.

The fees paid to Sanders’s media consultants far outstrip the salary earned by his campaign manager, Jeff Weaver, the senator’s former chief of staff, who had been in political retirement and was running a comic book shop in Virginia before joining the campaign. He has been paid about $103,000 through March, FEC filings show.

Many of the smaller vendors who have benefited from Sanders’s success are outside the usual Beltway consulting class. The campaign has paid $2.6 million for polling to Tulchin Research, a firm run by San Francisco-based pollster Ben Tulchin, who worked on the 2004 presidential campaign of former Vermont governor Howard Dean.

An additional $7.5 million went to Tigereye Design, a company in western Ohio that provides unions and Democratic campaigns with merchandise. The Sanders account is so large that it is now the company’s main focus, said owner Monica Baltes.

“I have been a supporter personally of Bernie Sanders for many, many years, so the people here, their hearts are in it,” she said. “It’s not just a money thing for us. It’s a passion.”

That’s the sentiment at First Step Print Shop, an eight-person outfit in Underhill, Vt. The company, owned by husband and wife Bob and Mary Martelle, has been doing work for Sanders’s campaigns for a decade. He kept them on the payroll for his presidential run, paying First Step nearly $400,000 through March for thank-you notes and business cards.

“We’re just a small piece of the pie,” said Bob Martelle. “There are so many different printers involved now. But it’s an honor. It’s quite the thing for our shop.”

It remains to be seen where Sanders’s money will flow in the coming weeks as he pares back his once-sprawling campaign and instead makes a targeted hunt for more delegates.

Devine rejected the idea that spending more resources is a lost cause, saying he believes Sanders can still narrow the gap with Clinton significantly. And he did not rule out putting more ads on the air, even in an expensive media state such as California.

“A lot will depend on resources we have available and where we are in the race,” he said. “We are ready to go. We have some advertisements that will be very powerful.”

John Wagner in West Lafayette, Ind., contributed to this report.

Correction: An earlier version of this article misspelled the name of the firm Devine Mulvey Longabaugh.