Nationalism was one of the major factors in the outbreak of WWI, as nationalistic movements caused deeply rooted conflicts between countries. This lead to a number of alliances between countries designed to protect national interests. When Serbian nationalists in Sarajevo assassinated Archduke Franz Ferdinand, the heir to the Austro-Hungarian throne, it caused a chain reaction between various alliances that led to the start of the war.
Europe was in a fragile and complicated state before the outbreak of WWI. Nationalism and imperialism were a deep source of conflict between many countries, as powers strove to gain more power in Europe and by controlling colonial territories abroad. This competition drove countries to form alliances with one another in order to protect their own interests, which were largely driven by nationalistic motives. Britain allied itself with France and Russia, whereas Austria-Hungary and Germany became central allies.
When the Ottoman Empire broke up in 1908, Bosnia became an Austro-Hungarian territory. However, Serbia felt it was entitled to the territory, as it was a Balkan state, which put it into direct conflict with Austria-Hungary.
After the assassination of Franz Ferdinand, Austria-Hungary officially declared war on Serbia. However, Austria-Hungary was allied with Germany, which promised to back its ally in the war. Russia was allied with Serbia, causing the power to enter the war. This caused a chain reaction as European countries entered the war to back their own allies, and eventually led to the involvement of the United States.