Most of the testimony we have from those who knew Lincoln earlier in life was that he was never a Christian believer, but they didn't have much contact with him in his later years and simply assumed he didn't change.
My understanding is based on Allen Guelzo's idea of Lincoln's "Calvinized Deism." You could read his book Abraham Lincoln: Redeemer President and see if you agree.
As a matter of fact, Lincoln's family were Primitive Baptists, and his own early flirtation with secular determinism may have actually been influenced by that background.
He felt bad for initiating a war of northern aggression, therefore, he turned to the word of God for salvation from his sin and guilt.