In a setback for gun-control advocates, a state appeals court has barred enforcement of a California law that would require all purchases of ammunition “principally for use” in handguns to be made in person rather than by mail order or on the Internet.

The law, which has been blocked by court orders since 2011, would require buyers of ammunition to be thumb-printed and sellers to keep records of the transactions.

Most types of ammunition are not limited to handguns, but can be used in rifles and other firearms, the Fifth District Court of Appeal said in a 2-1 ruling Wednesday. As a result, the court said, those affected by the law would not have fair notice of whether it applies to their transactions and when they might be at risk of prosecution.

Neither the law nor testimony by experts and gun dealers has provided “a common understanding or objective meaning of the term ‘handgun ammunition,’ ” said Justice Gene Gomes in the majority opinion. The law’s vague wording could lead to inconsistent and unpredictable enforcement, he said, and could make compliance difficult or impossible for mail-order and Internet ammunition .