The Deceuninck-Quick-Step rider completed the 171.4km stage in 3:48:18, with Alexander Aranburu (Caja Rural-Seguros RGA) and Fernando Barcelo (Euskadi-Murias) taking second and third just three seconds later.
“It was crazy, the atmosphere on the last climb. It was really like in the Classics with all the flags and everything,” said Gilbert, who won this year’s Paris-Roubaix.
“They gave me a lot of motivation. I’ve been racing a lot here in the Basque Country and I never had success. For me it’s the first and I’m happy because I think the Basque Country is like Flanders – they love cycling here.”
Earlier, South African Willie Smit (Katusha-Alpecin) launched an attack with 60km remaining which led to the establishment of today’s 19-man break.
Jonathan Lastra (Caja Rural-Seguros RGA), Felix Grossschartner (Bora-Hansgrohe) and Marco Marcato (UAE Team Emirates) attacked off the front of the break on the descent following the second climb of the day, the Alto de Urruztamendi, about 135km into the race.
Grossschartner was the first to hit the Alto de Vivero with 30km to go.
Tsgabu Grmay (Mitchelton-Scott) attacked on the climb and started chasing Grossschartner. He made it across to him a kilometre from the top of the third climb.
The duo were caught with 10km to go as the break reached the foot of the Alto de Arraiz.
Gilbert led up the climb and pushed ahead, with Aranburu and Barcelo chasing him.
Miguel Angel Lopez (Astana) then attacked the peloton, which was three minutes down on the break, with Primoz Roglic (Jumbo-Visma) on his wheel.
Gilbert maintained his lead all the way down to the finish in Bilbao.
The reduced peloton crossed the line 3:02 back. Roglic held on to the overall lead, with Alejandro Valverde (Movistar Team) second and Lopez third.
View the results below.
Stage 12 results
1. Philippe Gilbert (Bel) Deceuninck-Quick-Step 3:48:18
2. Alexander Aranburu Deba (Spa) Caja Rural-Seguros RGA +0:00:03
3. Fernando Barcelo Aragon (Spa) Euskadi Basque Country-Murias +0:00:03
4. José Rojas (Spa) Movistar Team +0:00:22
5. Nikias Arndt (Ger) Team Sunweb +0:00:26
6. Tosh Van Der Sande (Bel) Lotto Soudal +0:00:29
7. Cyril Barthe (Fra) Euskadi Basque Country-Murias +0:00:29
8. Manuele Boaro (Ita) Astana Pro Team +0:00:29
9. Tim Declercq (Bel) Deceuninck-Quick-Step +0:00:29
10. Valerio Conti (Ita) UAE Team Emirates +0:00:31
47. Willie Smit (RSA) Katusha-Alpecin +0:05:23
91. Nicholas Dlamini (RSA) Dimension Data +0:16:16
136. Jaco Venter (RSA) Dimension Data +0:17:56
152. Louis Meintjes (RSA) Dimension Data
1. Primoz Roglic (Slo) Team Jumbo-Visma 44:52:08
2. Alejandro Valverde (Spa) Movistar Team +0:01:52
3. Miguel Angel Lopez (Col) Astana Pro Team +0:02:11
4. Nairo Quintana (Col) Movistar Team +0:03:00
5. Tadej Pogacar (Slo) UAE Team Emirates +0:03:05
6. Carl Fredrik Hagen (Nor) Lotto Soudal +0:04:59
7. Rafal Majka (Pol) Bora-Hansgrohe +0:05:42
8. Nicolas Edet (Fra) Cofidis, Solutions Credits +0:05:49
9. Dylan Teuns (Bel) Bahrain-Merida +0:06:07
10. Wilco Kelderman (Ned) Team Sunweb +0:06:25
39. Louis Meintjes (RSA) Dimension Data +0:43:39
90. Nicholas Dlamini (RSA) Dimension Data +1:26:36
96. Willie Smit (RSA) Katusha-Alpecin +1:31:37
128. Jaco Venter (RSA) Dimension Data +1:59:26