A link to an online version of the Casa Grande Department of Parks and Recreation fall and winter activity guide included an attack ad leveled against Joe Ortiz, a Republican candidate for the Arizona state senate. The banner ad showed a photo of Mr. Ortiz in what looked like a police lineup and leveled several accusations against the politician, including assault and giving alcohol to a minor.

The ad was quickly pulled from the site, and the city’s webmaster said it was not aware that the ad was there. State law prohibits cities from using their resources to influence an election, according to Joseph A. Kanefield, a Phoenix-based Ballard Spahr litigation partner whose practice focuses on government relations and regulatory affairs.

Although the ad was probably inadvertent, “it could be perceived as using city resources to do just that,” Mr. Kanefield said. “It’s something the city should address.”