DETROIT — A Republican candidate for Michigan governor and ardent defender of former President Donald Trump was charged with misdemeanors Thursday for his role in the 2021 post-election riot at the U.S. Capitol, further complicating an already messy GOP primary.

Ryan Kelley, 40, was arrested in western Michigan and appeared at a hearing in federal court in Grand Rapids, where he was released from custody without posting bail. The government did not ask that Kelley be detained. Kelley is the first person running for election in a major state or federal race to be charged in connection with the attack.

According to a criminal complaint, Kelley was charged with committing violence against a person or property on restricted grounds, damaging federal property, disorderly conduct and entering a restricted building or grounds without permission.

His campaign posted on Facebook two words: “political prisoner,” and the chairman of the state GOP accused Democrats of “weaponizing our justice system” against political opponents.

Kelley’s arrest further roils a GOP field that initially had 10 candidates seeking to challenge Democratic Gov. Gretchen Whitmer in the battleground state this fall. Five of them, including two front-runners, were dropped from the primary ballot because forged signatures submitted by paid petition circulators left them below the 15,000 needed to make the race.

Kelley is among more than 800 people who are facing criminal charges in connection with the Jan. 6 riot.

The New York Times contributed.