Outspent and outmatched in her 2014 bid to reclaim a congressional seat she held for one term in the 1990s, former U.S. Rep. Marjorie Margolies engaged in what federal prosecutors have called a conspiracy to violate campaign finance laws.

Her campaign, they said, illegally spent money flagged for the general election in a bid to pull her across the finish line in the primary. Later, when asked to repay those funds, she accepted money raised by her top political strategist and forwarded it to her campaign, describing it on her finance reports as a personal loan.

But as she described those maneuvers to a federal jury Wednesday, the 76-year-old Democrat said it was the strategist – Ken Smukler – who assured her every step of the way that what she was doing was legal.

"My question to Ken was, 'Is this OK?'" she said. "His answer was yes."

Margolies' testimony came in the fifth day of Smukler's trial. A fixture in Philadelphia Democratic circles and U.S. Rep. Bob Brady's longtime political guru, Smukler is charged with violating federal campaign law while working on Margolies' campaign and in a reelection bid for Brady in 2012.

But as Margolies delivered her own account of her 2014 campaign, the circumstances under which she was testifying were almost as remarkable as what she said.

Margolies – whose daughter-in-law is Chelsea Clinton and who has also been a Democratic candidate for lieutenant governor — spoke under a grant of immunity from prosecution.

Testifying Wednesday, she maintained that she never believed she had broken the law – a fact that Smukler's lawyer, Brian McMonagle, emphasized during his cross-examination.

Since Smukler was indicted last year, McMonagle has questioned both in and out of court how if what the strategist did was illegal, the candidates with whom he did it aren't seated alongside him at the defense table.

For her part, Margolies described the 2014 primary campaign – a four-way race, won by Brendan Boyle, to replace former Rep. Allyson Y. Schwartz in the 13th District – as hectic and stressful. Vying for the opportunity to again represent parts of Philadelphia and Montgomery County, she said she was surprised at how quickly her bid foundered – as were others involved in the race.

Jonathan Saidel, Philadelphia's former controller, told the jury that he at one point had mulled running but considered Margolies a formidable opponent given her connection to the Clintons and their donors, and the support she had in Washington.

"It was my assumption President Clinton was going to swoop into Northeast Philadelphia and hold a rally for her, and it was going to catapult her into winning the primary," he said. "If, in 2013, Clinton had come to Northeast Philadelphia, my own mother would have gone to that rally."

Saidel described being summoned to an early 2014 meeting at which Brady and Smukler tried to persuade him to not run against Margolies. The congressman, he said, handed him a phone with then-House Minority Whip Steny Hoyer on the other end to demonstrate that Margolies had Washington's backing.

Saidel left that meeting with an offer to join Margolies' campaign. But signs of trouble were already apparent as Boyle, with strong union backing, was proving to be stiff competition.

By April 2014, the Margolies campaign had run out of money that it could legally spend in the primary. So, as prosecutors tell it, Smukler illegally tapped contributions that had been earmarked for the general election. Federal campaign finance laws forbid such spending and require that losing primary candidates refund all money given to them to support a general election run.

When Margolies lost to Boyle by more than 14 percentage points, she and Smukler did not have enough to pay back her contributors.

Prosecutors allege that to raise the necessary funds and hide what he had done in the earlier phase of the campaign, Smukler solicited $225,000 from his brother and a friend, and routed it through his consulting and communications companies back to Margolies' campaign, which falsely described the transfers as reimbursements.

The Federal Elections Commission later discovered that Smukler's businesses had "refunded" the campaign more than it had paid him in the first place. To fix the problem, the government says, Smukler wrote a $25,000 check from one of his companies to Margolies and told her to transfer the bulk of that money back to her campaign.

Margolies later reported the money as a personal loan on behalf of the candidate. Prosecutors now describe it as an illegal contribution from Smukler.

Smukler also is accused of obstructing a later FEC investigation into those transaction based on a complaint filed by State Sen. Daylin Leach, who was also a candidate in the 2014 race.  The FEC dismissed the complaint.

At trial, Smukler has argued that he did legal research to back up his actions and assure himself that the transactions he undertook to repay Margolies' donors were legal. Even if he was wrong, he has argued, he never intended to break the law.

Dylan McGarry, Margolies' former campaign manager, echoed that sentiment in an internal campaign email presented to jurors Wednesday.

"Your research said that the FEC wasn't even fining people for this," McMonagle said while questioning the campaign manager, "let alone indicting them."

But despite McGarry's and Margolies' views about the legality of the campaign's financial moves, prosecutors persistently sought to emphasize just who it was who convinced them.

"Who told you this was legitimate?" asked prosecutor Richard Pilger while questioning Margolies.

The ex-congresswoman's reply: Smukler.