The Kentucky official who sparked an international uproar for her refusal to issue marriage licenses to same-sex couples has lost her bid for re-election as Rowan County clerk.

Kim Davis, a Republican, was defeated by Democratic challenger Elwood Caudill, 54 percent to 46 percent, to serve a four-year term, according to the Associated Press.

Davis spent five days in jail for ignoring court orders to issue licenses to same-sex couples following the U.S. Supreme Court's 2015 ruling allowing gay marriage. She said she was acting "under God's authority." Davis was freed only when a judge ordered her deputies to issue the licenses without her approval.

GET 2018 ELECTION RESULTS HERE

The latest:Kim Davis tacked right on gay marriage, but the right didn't want her

Davis has said she no longer objects to issuing the licenses because Kentucky dropped a requirement that the licenses bear the clerk’s signature. But she has maintained her opposition to same-sex marriage, visiting the Eastern European nation of Romania last October to urge it to amend its constitution to prohibit it, the Courier Journal previously reported.

Caudill is a 20-year employee of the county's property valuation office and a fourth-generation Rowan County resident. In a four-person Democratic primary, he soundly defeated a man whose marriage license Davis refused to sign in 2015.

Related:Who is Elwood Caudill? He's the man who beat anti-gay clerk Kim Davis

You may like:Kentucky's Kim Davis might have played a role in Vatican infighting

In a surprise twist, Caudill was later accused of being an anti-gay bigot by the man, David Ermold.

"I just want him to lose. I would rather Kim Davis win," Ermold told the AP in September. "At least Kim Davis has the integrity to stand up for what she believes in. Elwood Caudill is a liar."

Davis had no opposition as a Republican. She was previously a Democrat, defeating Caudill by 23 votes in the 2014 Democratic primary. She is the daughter of the county's previous clerk, Jean Bailey.

Reach reporter Alfred Miller at amiller@gannett.com or 502-582-7142. Follow him on Twitter @AlfredFMiller. Support strong local journalism by subscribing today: courier-journal.com/subscribe.

Background:In Kim Davis race, her opponent is the one being accused of bigotry

For hoops fans:Retro Kentucky basketball vs. Duke: The battle of the blue bloods