After Carly Fiorina’s unsuccessful 2010 run for Senate in California, it took her more than four years to fully pay staff and vendors for their work on her campaign to unseat Democratic Sen. Barbara Boxer.

But a review of Federal Election Commission records by The Daily Beast shows that Fiorina first paid herself back for more than $1.25 million in personal loans she made to the campaign, including a $1 million check on the day before Election Day. That check set the campaign back so far it was impossible to pay staff and vendors what they were owed for years.

Marty Wilson, Fiorina’s then-campaign manager, said Fiorina knew at the time that there would be debts at the end of the campaign, but that it was difficult to know how deep the debt would be.

“The problem with campaigns is you project debt based on what you think revenues are going to be,” Wilson said. “People say they are going to send money, but Election Day comes and goes, and you’ve lost, and those receivables don’t materialize.”

With more than $1 million out the door at the last minute and a shortfall in fundraising commitments, the campaign ended nearly $500,000 in debt, unable to pay vendors and staff, including Wilson, who was owed more than $60,000.

“We certainly talked to her after the campaign quite a bit about the nature of the debt, who the money was owed to, did some things to get some of the bills paid off after the election,” Wilson said. “Was I frustrated? Yes. But there were other people who were more frustrated than I was.”

The best part? This is totally, 100 percent legal.

Under federal law, self-funding candidates can spend unlimited money on their campaigns. Some donate the money outright, while others, like Fiorina, make loans to the campaign with the hopes of being paid back once the money is raised from other sources.

But the loans are not indefinite. The 2002 McCain-Feingold Act limits the window during which a candidate can be reimbursed for those candidate-sponsored loans, which could explain Fiorina’s haste to get at least some of her money back.

Paul S. Ryan, senior counsel at the Campaign Legal Center in Washington, D.C., said the law was supposed to keep lobbyists from paying candidates’ campaign expenses, but it also entices candidates to repay themselves quickly or never be paid back at all.

“The unfortunate thing in this scenario is that a bunch of other vendors and staff were seemingly shafted by this move,” said Ryan. “It’s not illegal, but one may draw their own conclusions about the type of person who would rather pay themselves back a loan, when they are free to spend as much money as they want on their campaign, rather than repay others who they owe money to.”

Even going into the campaign, it was clear the Senate bid would be a wildly expensive proposition for any Republican candidate. Fiorina, a first-time candidate who had made her name, and much of her estimated $120 million personal fortune at that time, as the CEO of Hewlett-Packard from 1999 until 2005, was no exception.

Although Fiorina’s run at HP was rocky, with more than 30,000 layoffs and a stock that lost more than half its value, Fiorina left with a $21 million payout and more than $20 million more in additional compensation.

Altogether, Fiorina financed nearly $7 million of the $21 million Senate campaign through personal loans to her campaign at 0 percent interest. In November 2009, she launched Carly for California and quickly pumped $2.5 million into the nascent Senate bid. She then repeatedly dipped into her personal fortune as the campaign went on, including a $1 million loan in the final weeks of the campaign to pay for a last-minute ad buy against Boxer.

Having declared all of her loans during the primary as a loss, Fiorina paid herself back in full for loans she made in the general election, using cash on hand to repay herself $250,000 two weeks before the election and $1 million on the day before Election Day.

Over the next four years, the Carly for California campaign pushed its debts back month after month after month, year after year. As Fiorina and her husband relocated to a multimillion-dollar Virginia estate and campaign treasurers came and went, the vendors and staff remained unpaid, including the widow of a close adviser who had died suddenly during her Senate bid.

Only as Fiorina began to publicly consider launching a presidential campaign in 2015 did she pay off her 2010 debts, quietly writing a personal check for $487,410 to finally pay the outstanding bills and close the Carly for California campaign.

Three months later, Carly for President launched, quickly raising $1.4 million for Fiorina’s presidential bid. But unlike Carly for California, the new campaign is making do without her personal fortune. So far, she and her husband, Frank, have given $2,700 each, the maximum allowed for any average donor.

That may be partially explained by Marty Wilson’s observation of Fiorina’s 2010 experience. “I don’t think anybody likes parting with a substantial percentage of their net worth for a speculative venture.”

The Carly for President campaign did not respond to a request for comment on this story.