For the thousands of tourists who visit the northern Spanish town of Pamplona every July, the San Fermin festival is all about the running of the bulls, but for locals it is an important religious festival and a celebration of Basque folklore and tradition.

Pamplona San Fermin festival 2017
Pamplona San Fermin festival 2017
Pamplona San Fermin festival 2017
Pamplona San Fermin festival 2017
Pamplona San Fermin festival 2017

The festival is held in honour of Saint Fermin, patron saint of Navarra and first bishop of Pamplona, who is believed to protect those who participate in the running of the bulls. Fermin is said to have been the son of a Roman senator who lived in the third century. He was ordained as a priest in France and returned to Pamplona as its first bishop.

According to legend, he was beheaded on 25 September 303 and is now considered a martyr in the Catholic Church. Some say he was dragged through the street with bulls chasing him, hence the tradition in Pamplona.

Pamplona San Fermin festival 2017
Men carry a figure of San Fermin during a procession in PamplonaPablo Blazquez Dominguez/Getty Images
Pamplona San Fermin festival 2017
Children watch out from window as a figure of the saint passes during the annual San Fermin procession in PamplonaPablo Blazquez Dominguez/Getty Images
Pamplona San Fermin festival 2017
A woman prays during the procession of San Fermin on the saint's day in PamplonaSusana Vera/Reuters
Pamplona San Fermin festival 2017
A man carrying ears of wheat takes part in the San Fermin procession in PamplonaPablo Blazquez Dominguez/Getty Images
Pamplona San Fermin festival 2017
A man claps during the procession of San Fermin on the saint's day in PamplonaSusana Vera/Reuters
Pamplona San Fermin festival 2017
A medallion of Saint Fermin hangs from the neck of a man during the procession on the saint's day in PamplonaSusana Vera/Reuters
Pamplona San Fermin festival 2017
A participant touches a picture of Saint Fermin before the start the third bull run of the San Fermin festival in PamplonaAnder Gillenea/AFP
Pamplona San Fermin festival 2017
The mayor of Pamplona Joseba Asiron doffs his top hat as he takes part in a procession during the San Fermin festivalCesar Manso/AFP

The annual festival kicks off with the traditional firing of a rocket called the Chupinazo, which is followed by a wine-soaked celebration in the city square.

Pamplona 2017 San Fermin Chupinazo
The Chupinazo rocket is fired from the Pamplona town hall to mark the start of the San Fermin festivalCesar Manso/AFP
Pamplona 2017 San Fermin Chupinazo
Revellers pour wine into another's mouth as the festival beginsCesar Manso/AFP
Pamplona 2017 San Fermin Chupinazo
A naked reveller is thrown into the air during the official launch of the San Fermin festivalAnders Gillenea/AFP
Pamplona 2017 San Fermin Chupinazo
The Pamplonesa band performs in front of the city's town hallAnder Gillenea/AFP

Giant figures are paraded through the city every morning of the festival. These figures, known as kilikis, chase children and hit them with a sponge.

Pamplona San Fermin festival 2017
People watch the parade of 'Gigantes y Cabezudos' (Giants and Big Heads) as part of the San Fermin festival in PamplonaCesar Manso/AFP
Pamplona San Fermin festival 2017
A woman and her baby are attacked by a kiliki holding a sponge during the San Fermin festival in PamplonaJoseba Etxaburu/Reuters
Pamplona San Fermin festival 2017
A girl laughs as she is chased by a "cabezudo" (big head) during the San Fermin festival in PamplonaEloy Alonso/Reuters
Pamplona San Fermin festival 2017
A "kiliki" (big head) chases and hits children during a parade at Pamplona's San Fermin sestivalAnder Gillenea/AFP
Pamplona San Fermin festival 2017
A "zaldiko" (horseman) hits people with a sponge during a parade as part of the San Fermin festival in PamplonaCesar Manso/AFP
Pamplona San Fermin festival 2017
A child looks at Caravinagre (Vinegar Face) during a parade as part of the San Fermin festival in PamplonaCesar Manso/AFP
Pamplona San Fermin festival 2017
A "cabezudo" (big head) stands next to revellers during the Comparsa de Gigantes y Cabezudos paradePablo Blazquez Dominguez/Getty Images

A metal bull spouting fireworks from its horns terrifies those too young to take part in the running of the bulls.

Pamplona San Fermin festival 2017
Revellers run from the Fire Bull, a man carrying a bull figure packed with fireworks, at the San Fermin festival in PamplonaEloy Alonso/Reuters
Pamplona San Fermin festival 2017
Children run in the the "Encierro Txiki" (Small Bull Run) during the San Fermin festival in PamplonaMiguel Riopa/AFP
Pamplona San Fermin festival 2017
A child runs pushing a toy bull on a street in Pamplona during the San Fermin festivalMiguel Riopa/AFP
Pamplona San Fermin festival 2017
People run away from a Toro del Fuego (flaming bull) on the streets of PamplonaPablo Blazquez Dominguez/Getty Images

The festival is also a celebration of traditional Basque pursuits such as stone carrying, wood carving and hay bale lifting. Traditional dances attended by the locals are held every evening, while the tourists engage in yet another bout of drinking themselves into a stupor, perhaps to give them enough courage to face the bulls – or an excuse not to have to.

Pamplona San Fermin festival 2017
People take part in the traditional "Baile de la Alpargata" (Espadrille Dance) during the San Fermin festivalMiguel Riopa/AFP
Pamplona San Fermin festival 2017
Men perform a traditional Basque dance in a street during the San Fermin festival in PamplonaAnder Gillenea/AFP
Pamplona San Fermin festival 2017
People sing and play traditional music after having lunch in a street during the San Fermin festival in PamplonaAnder Gillenea/AFP
Pamplona San Fermin festival 2017
A man stands next to graffiti reading, "Freedom For The Basque Country" at the San Fermin festival in PamplonaVincent West/Reuters
Pamplona San Fermin festival 2017
A street vendor wears hats in traditional festival colours on the first day of the San Fermin festival in PamplonaVincent West/Reuters
Pamplona San Fermin festival 2017
Revellers pose with a statue of US writer Ernest Hemingway during the San Fermin festival in PamplonaEloy Alonso/Reuters
Pamplona San Fermin festival 2017
Revellers sleep before the second running of the bulls at the San Fermin festival in PamplonaEloy Alonso/Reuters
Pamplona San Fermin festival 2017
Revellers sleep on the grass at the San Fermin festival in PamplonaSusana Vera/Reuters
Pamplona San Fermin festival 2017
A reveller leaning on a wall sleeps in a street during the San Fermin festival in Pamplona,Miguel Riopa/AFP