The infamous James Buchanan is commonly ranked among the worst Presidents, just like many Presidents close before or close after Lincoln.
Buchanan was a one-term President and our only life-long bachelor President. He was active on the political field well before his presidency- he was elected to the House of Representatives 5 times, and served as Minister to Russia, Polk's Secretary of State and Pierce's Minister to Great Britain, which helped earn him the Democratic nomination. Critics would call him a "doughface"- a Northerner with Southern sympathies.
He thought of the territorial question of restricting slavery as a non-issue in the beginning of his presidency. The Dred Scott case ruled that the government could not take away "property" rights in the territories, and Buchanan urged that the Kansas territory be admitted as a slave state to end the violent tension therein, both moves alienating Democrats and angering Republicans.
Due to a Republican plurality in Congress, the government reached a stalemate as no bills were passed. Lincoln rose to popularity among Republicans as the Democratic party split into a north and south wing, just as many Southern states began crying 'secession.' Buchanan tensely denied the legal right of a state to secede while simultaneously denying the government's right to stop them.
Towards the end of his term, as cabinet members resigned, he appointed many Northerners and sent reinforcement troops to Fort Sumter (though these troops were not present at the time of the attack in 1861).
Due to Buchanan's weak stance over the question of slavery in territories and the government's rights in allowing or preventing it, as well as his lack of action over the continuing divide in the country, Buchanan's term saw the climaxing of tensions leading to the Civil War.
Sources: White House.gov, Wikipedia, Biography.com