The immediate cause of the Civil War was the attack on Fort Sumter by Confederate batteries in April of 1861. This led Abraham Lincoln to issue a call for troops to crush the rebellion, which in turn caused Virginia, Tennessee, North Carolina, and Arkansas to secede from the Union. After this event, the Civil War was on.
The underlying causes of the war were more complex, but can be traced to the divisive issue of slavery. Long a simmering issue, it became particularly toxic in the aftermath of the Mexican War, which raised the question of the expansion of slavery into the western territories. This political issue was increasing powered by the moral force of the abolitionist movement in the North. While most Northerners were not abolitionists, many were beginning to resent what they saw as the South's attempts to control the nation's politics. In the South, on the other hand, there was a fear that Northern sentiment was turning against them, and that if the federal government fell into the hands of antislavery men, they might move against slavery. The fact that the industrial North and the agricultural South were drifting apart culturally and economically exacerbated matters--slavery, in fact, was a leading cause of this divergence as well.
The Kansas-Nebraska Act, which permitted popular sovereignty (a vote) on the issue of slavery in Kansas, where slavery was previously prohibited, destroyed the so-called second two-party system, introducing a new party, the Republicans, devoted to resisting the expansion of the institution. When Abraham Lincoln, a Republican, was elected in 1860, South Carolina led the states of the lower South out of the Union, which set the stage for the more immediate causes.
In a few words, the immediate cause was secession and firing on Fort Sumter, and the underlying cause was the political issue of slavery.