Members of the national guard or militia ordered into the active service of the state by any proper authority are not civilly nor criminally liable for any act or acts done by them in the line of duty. Members of the national guard or militia ordered into active service of the state must be presumed to be acting in the line of duty except in the case of willful misconduct or gross negligence. When a suit or proceeding is commenced in any court against an officer of the militia for any act done by such officer in the officer's official capacity in the discharge of any duty under the provisions of this title, or against any person acting under the authority or order of any such officer or by virtue of any warrant issued by any such officer pursuant to law, the defendant is entitled to legal representation provided by the attorney general, an assistant attorney general, or a judge advocate officer at no cost. The defendant in such action may require the person prosecuting or instituting the suit or proceeding to file security for the payment of the costs that may be awarded to the defendant therein. The defendant in all such cases may make a general denial and give the special matter in evidence. If the action is dismissed or a verdict or judgment is rendered against the plaintiff, the defendant shall recover treble costs in the action.
N.D.C.C. § 37-01-12