LOUISVILLE, Ky. — The Kentucky clerk who went to jail in 2015 for refusing to issue marriage licenses to same-sex couples lost her bid for a second term on Tuesday.

Kim Davis, the Republican incumbent, was defeated by Democrat Elwood Caudill Jr. in the election for clerk of Rowan County in northeastern Kentucky. Caudill won with 4,210 votes, or 54 percent, to 3,566, or 46 percent, for Davis.

"I believe that as a community we must continue to work together toward a more prosperous and cohesive Rowan County," Caudill said after his win, according to the Lexington Herald-Leader.

Davis became a national figure when she stopped issuing marriage licenses days after the U.S. Supreme Court ruled that the U.S. Constitution guarantees same-sex couples the right to marry. The ruling overturned same-sex marriage bans nationwide. Davis cited her religious beliefs, saying she was acting under "God's authority." She was released from jail when her staff issued licenses in her absence.

Rowan County voters denied Davis another term to a job that pays about $80,000 a year. She was elected to the clerk's job as a Democrat in 2014, but later switched parties because she said the Democratic Party "abandoned her."

She didn't back away from her stand, saying at a fall campaign debate that she didn't treat anyone unfairly, and that she took an oath to uphold the constitution. She said she treated everyone equally because she quit issuing marriage licenses altogether.

At the same debate, Caudill said if elected he would treat everyone equally because he took an oath to uphold the law.

Caudill criticized Davis for hiring her son to work for her. Davis defended the hiring, saying her son is someone she can trust to oversee human resources and handle the office computers.

Kentucky voters in 2004 overwhelmingly approved an amendment to the state Constitution defining marriage as between one man and one woman. But in June 2015, the U.S. Supreme Court ruled the 14th amendment to the U.S. Constitution guarantees same-sex couples have the right to marry. The ruling overturned same-sex marriage bans nationwide.

Days after the ruling, Davis stopped issuing marriage licenses.

She was sued by gay and straight couples, and a federal judge ordered Davis to issue the licenses. She refused and spent five days in jail.

She was released only after her staff issued the licenses on her behalf but removed her name from the form. The state legislature later enacted a law removing the names of all county clerks from state marriage licenses.

A federal judge later ruled Kentucky taxpayers must pay the couples' legal fees of about $225,000.

FOLLOW NBC OUT ON TWITTER, FACEBOOK AND INSTAGRAM