A judge in the US state of Kentucky has released a county clerk who refused to issue marriage licences, citing her religious opposition to gay marriage.
A US county clerk jailed in Kentucky for refusing to issue marriage licences to gay couples has praised God and thanked supporters after a judge ordered her release.
Kim Davis, a born-again Christian, was jailed last week for contempt of court after refusing to issue licences due to her opposition to same-sex marriage, which the Supreme Court legalised across the United States in June.
The 49-year-old - who has argued she should be exempt from following the law because of her religious beliefs - has become a heroine for millions of Americans and rekindled a thorny debate about gay marriage.
Davis was overcome with emotion on Tuesday as she climbed onto a flatbed truck to address the large crowd of supporters gathered outside the Kentucky jail to greet her, the sound of Survivor's Eye of the Tiger drowning out their cheers.
"I just want to give God the glory," she said, after thanking those at the rally.
"We serve a living God who knows exactly where each and every one of us is at. Just keep on pressing. Don't let down because he is here. He's worthy."
Supporters waved white crosses and signs declaring "Religious Freedom" and "Courts Don't Make Laws".
The federal judge who ordered Davis held on contempt charges ruled she could be released because five of the six deputy clerks in Rowan County "stated under oath that they would comply with the Court's Order and issue marriage certificates to all legally eligible couples".
Davis was ordered not to "interfere in any way, directly or indirectly" with the issuance of marriage certificates, Judge David Bunning wrote, warning of "appropriate sanctions".
Republican presidential hopefuls have jumped on the Davis bandwagon, capitalising on the image of an outspoken Christian woman heading to jail as evidence for their claims people opposed to gay marriage are suffering religious persecution.
Mike Huckabee, a Baptist minister and former governor of Arkansas, walked out of the jail with Davis. Rival Ted Cruz also met with her and her husband but did not speak at the rally.
"I know there are some people who will say this is a rally of hate. They would be wrong," Huckabee told the crowd.
"We gather here today because we love God and we love this great country."
Bunning had previously said Davis could be released from jail as soon as she agreed to issue marriage licences to anyone who qualifies, as her position requires, or resigned from her government job.
But her intentions about her job remain somewhat unclear.
"Kim Davis will not violate her conscience," lawyer Mathew Staver said.
"She cannot allow her name to be associated with something that conflicts with God's definition of marriage."
She also has no intention of resigning, he told the crowd.
Rowan County handed out its first certificate to a same-sex couple on Friday. The licence was altered so that "Rowan County" rather than "Kim Davis" appeared on the line reserved for the name of the clerk.
Davis stopped issuing all marriage certificates in mid-August following the Supreme Court's landmark June 26 ruling legalising gay marriage.