ANCHORAGE (Reuters) - A legal defense fund for former Alaska Governor Sarah Palin was illegal and must repay nearly $400,000 to donors, according to a settlement with a state-appointed lawyer announced on Thursday.

Former Governor of Alaska Sarah Palin and her husband Todd (R) leave the paddock at the 142nd Belmont Stakes, the final leg of racing's Triple Crown, at Belmont Park in Elmont, New York June 5, 2010. REUTERS/Jessica Rinaldi

But Palin, the feisty former Republican vice presidential candidate who has become a fixture of the conservative Tea Party movement, probably violated a state ethics act without knowing she was doing so, independent counsel Tim Petumenos said.

While governor, Palin faced some two dozen ethics complaints, which she said left her with a legal bill of more than $500,000. Her political action committee raised a fund to pay for her defense.

A preliminary ruling by another independent counsel last year said the fund was illegal because it used her official position as governor to raise money for her personal gain.

Petumenos confirmed the decision and said no such legal defense fund had ever been set up before for a state official in Alaska.

Palin violated the ethics rules because she was a beneficiary of the fund but probably relied on bad advice from out-of-state lawyers to conclude it was above board, Petumenos said at a news conference.

He added that Palin should have checked with the state attorney general before pursuing the fund.

“It is the responsibility of every public official to make sure they are personally compliant with the (Alaska Ethics) Act,” he said.

The deal requires Palin’s fund to give back to donors $386,856 collected while she was in office. A further $33,546 collected after she resigned will not be affected by the deal.

Palin, no longer a public official, has launched a new defense fund. She is now independently wealthy but her lawyer, Thomas Van Flein, told reporters he still believed she ran up the legal costs in her capacity as governor and so a new fund was justified.