The Polish national anthem was written in July 1797 in Reggio near Bolonia by Józef Wybicki, one of the organisers of General Jan Henryk Dąbrowski's Polish Army in Italy. The theme of the original poem was a novel idea in the era of the nation state (that is, most European nations were made up of eponymous nationalities), that the nation does not need a territory to be a nation, it only needs a group of people. This idea was a timely one, as Poland had only been partitioned out of existence only two years earlier. Several more times in subsequent Polish history would an independent Polish nation appear then disappear from the map, which could explain why the song resonates with Poles even today. The original poem also mentions several Polish war heroes of the time, as well as heroes of past Polish wars; also Napoleon is mentioned, as the commanding officer of Dąbrowski and as an example to be held up.
The source of the melody is unclear; it is usually ascribed to Michal Kleofas Oginski, but this has not been determined with certainty. It is most likely based on an anonymous folk song, due to the unusual mazurka tempo (which is often played at a faster rate than most anthems); mazurkas originated in Poland and have always been heavily associated with that nation.
Its familiar mazurka melody and its message - a call to join the fight for independence - inspired numerous 19th century patriotic songs and national hymns of the Slavonic nations under foreign rule (some of which would later become Yugoslavia, which could explain the similar melody of the former Yugoslav anthem.) The opening line of the lyrics was also borrowed by Ukraine (which, of course, speaks of the Ukraine not perishing rather than Poland.) In the early years after Poland's revival in 1918, during the debate about the choice of the national anthem, several candidates were considered. On February 28, 1927 the choice of "Dąbrowski's Mazurka" as the national anthem was officially announced.