The immediate cause of World War I was the assassination, in Sarajevo, of the Archduke Franz Ferdinand, heir to the Austrian throne. The assassination, which was carried out by a Serbian nationalist, led to an Austrian military response that triggered a declaration of war by Russia. Germany, Austria's ally, then declared war on Russia and found itself at war with Russia's allies, France and Britain.
The underlying reason for this domino-like progression of declarations of war was the political alignment of Europe in 1914. At the heart of the tension was the ongoing rivalry between Germany and the British Empire over control of the sea and access to colonial markets. Germany lacked overseas possessions and was in the process of building a large, modern navy. The British took this as a direct threat to their position and began seeking allies in Europe to contain German aggression. It was this elaborate network of alliances and mutual-defense pacts that set the stage for an event, any event, to trigger war. Once Austria declared war on Serbia, Russia was bound by its pledge of protection to enter the war, as was Germany. Britain and France were likewise bound to Russia, making a global conflict inevitable.