NEW YORK — A former City Council member with a history of anti-gay views has been appointed to lead faith-based initiatives in the Adams administration.

In a lengthy Facebook post, Fernando Cabrera apologized for his past remarks and his contrition was accepted by Adams in a statement late Monday.

“Fernando Cabrera has acknowledged the pain that his past comments have caused and has apologized for the words he used,” Mayor Eric Adams said in a statement. “I heard and accepted his apology. As a man of faith, I have made clear that our administration will serve all New Yorkers equally and fairly.”

Cabrera, a Christian pastor from the Bronx, will be a senior adviser in the new Office of Faith-Based and Community Partnerships.

Adams’ consideration of the Cabrera for a post in his administration was met with widespread concern and criticism.

Cabrera said he was “deeply sorry for the undue pain and suffering,” including praise for the Ugandan government in 2014 after it passed an “anti-homosexuality” bill.