Turkish authorities on Wednesday freed an American pastor held for nearly two years on controversial terrorism charges, setting the stage for resolution of a case that has strained U.S.-Turkish relations.

Andrew Brunson, who was arrested in 2016 amid a nationwide crackdown in Turkey following a failed military coup, was released from jail and allowed to return to his home on the Turkish coast as his attorney said the pastor could be allowed to return to the U.S. within days.

“For...