MOREHEAD, Ky. — Kim Davis, the Kentucky county clerk who refused to sign marriage licenses for same-sex couples, lost Tuesday in her re-election bid for the Rowan County clerkship.

Davis, a Republican, lost to Democratic challenger Elwood Caudill Jr. by about 700 votes. Her loss marks at least temporarily an end to the controversy that has surrounded the clerk’s office since 2015, when Davis was jailed for five days after refusing to sign marriage licenses for same-sex couples.

The controversy gave Davis a hero’s reputation to some on the right, including Gov. Matt Bevin and former Arkansas Gov. Mike Huckabee, who praised her decision as a self-sacrificing expression of religious liberty.

Davis was strongly criticized by many on the left. Critics called her refusal to sign marriage licenses a bigoted neglect of her official duties.

Since her incarceration and subsequent rise to fame, Davis continued to work as clerk and published a book about her experience, “Under God’s Authority: The Kim Davis Story.”A description of her book reads: “Kim chronicles her dramatic encounters with furious, fist-pounding homosexual men and the hate mail that flooded her office.”

But despite Davis’ fame, Caudill, the chief deputy property valuation administrator for Rowan County, won the election. This was Caudill’s second time running for the office.

In 2014, he lost to Davis by just 23 votes in the primary. Davis changed parties in 2015.

Much of the attention to Caudill’s campaign focused on his primary opponent David Ermold, a gay man who was denied a marriage license by Davis in 2015.

Ermold’s campaign for county clerk received more than $200,000 in donations from supporters across the country. Despite the financial advantage — Caudill raised $6,000 for his primary bid — Ermold lost the primary by more than 1,000 votes.

After his loss, Ermold declined to support Caudill. Instead, he has called Caudill a homophobe and said the Kentucky Fairness Campaign’s endorsement of Caudill was “personally offensive.”

Caudill repeatedly denied Ermold’s accusations of bigotry. He said that when it comes to marriage licenses, he plans to treat everybody equally.

-- Will Wright, Lexington Herald-Leader via The Associated Press