Brownlee completed the gruelling three-discipline race with a total time of 1:46:25.
Alistair Brownlee was fifth after the swim and led the bike stage towards the end before heading into the run in third overall.
He moved into the lead in the run at the start and held his nerve to stay ahead of Gomez and take the win.
Gomez led after the swim but slipped back to sixth after the bike phase and could not get past Brownlee, having to settle for silver with his 1:46:36.
His brother Jonathan took bronze comfortably with a time of 1:46:56 despite being made to do a 15-second penalty.