He won the Civil War, ended slavery, had his bust carved into Mount Rushmore and now beams from five dollar bills. But the God-fearing patriots of Middle America are about to receive a reminder that Abraham Lincoln had a strained relationship with one of their most respected institutions: organised religion.

A three-page letter highlighting the 16th president's unconventional relationship with the Almighty has just been put on sale. It offers a possible insight into why he was never baptised, did not attend a church and, in defiance of political protocol of the era, would refuse to publicly discuss his spiritual beliefs. Such was his reluctance to embrace piety that, if he were standing for office today, there is a good chance he would be unelectable.

The letter was written by William Herndon, a legal partner and close friend of "Honest Abe" in 1866, a year after Lincoln had been assassinated by John Wilkes Booth. And while the letter is at pains to stress that Lincoln did believe in "a God" at the time of his death, it reveals that he took a long time getting to that point. "Mr Lincoln's religion is too well known to me to allow even a shadow of a doubt; he is, or was, a Theist and a Rationalist, denying all extraordinary, supernatural inspiration or revelation," it reads, before detailing the president's spiritual evolution in the years after Herndon met him in Springfield, Illinois, in the 1840s.

"At one time in his life, to say the least, he was an elevated Pantheist, doubting the immortality of the soul as the Christian world understands that term. He believed that the soul lost its identity and was immortal as a force. Subsequent to this, he rose to the belief of a God, and this is all the change he ever underwent. I speak knowing what I say. He was a noble man – a good great man for all this."

Historians have long debated Lincoln's religious views, and how they affected his political career. He was born into a humble Kentucky family in 1809 and raised as a Baptist, but became sceptical and rejected organised religion. He never joined a church in his adult life. After being elected to the White House in 1860, he suffered the death of his 11-year-old son. That, along with the Civil War, in which he served as commander-in-chief and the nation's most senior abolitionist, are believed to have awakened his sense of spirituality.

The letter from Herndon, whose relationship with the president was limited to the years before he was elected, is being sold for $35,000 (£21,500) by the Raab Collection. "People debate Lincoln's religion today," Nathan Raab, its vice-president, told reporters this week. "This letter brings that debate into the foreground. He did believe in God, however difficult it might be to easily define those beliefs."

A couple of decades after Lincoln's death, several biographers attempted to portray him as a Christian. They were helped by the fact that he often quoted the Bible during speeches.