Crossing the Budapest finish line of the 9.2km time-trial 03sec faster than Mathieu van der Poel, who retained the overall lead, while Tom Dumoulin was third.
The Dutch maverick Van der Poel retains the lead in the overall standings by 11 seconds from Yates while the 2017 champion Dumoulin is third at 16sec after the inner-city run, the second of three stages in Hungary before a switch to Italy.
Yates timed 9min 50sec round the picture-postcard run around the monuments and sights of the city with its Gothic parliament, Danube river and thermal baths.
The circuit, with its tight bends and varying surfaces and gradients, made the stage a test of bike-handling skills, although the forecast rain held off.
Third in the Giro last year Yates has never been known for time-trialling, but with only 26km of the discipline on the 2022 route the mountains are the more important terrain.
“We have worked hard on the time-trial bike and wanted to go as fast as possible here,” Yates said who flew over the cobbled section where others appeared to bounce around.
This was Yates’ fifth stage win on the Giro.
“We’ll celebrate this tonight but it’s a tiny section of the Giro, with all those mountains coming up,” he said.
Yates led the Giro for almost two weeks in 2018 before a late meltdown and has promised to be more patient this time round.
Van der Poel was rueful of his narrow miss of a second stage win in two days following his triumph at the Visegrad Citadel Friday.
“I would have loved to win, the difference between winning and second is very close, isn’t it?” said the Alpecin rider who wore the Tour de France yellow, as race leader, for six days last year.
Pre-Giro favourite Richard Carapaz came 19th at 28sec, while another fancied rider Romain Bardet was 17th at 24sec.
Astana’s Miguel Angel Lopez and Mikel Landa of Bahrain Victorious both dropped more time than expected.
Sunday’s stage, the last of the Hungarian trio, is a flat 201km race from Kaposvar to Balatonfured. It should end in a mass bunch sprint when Mark Cavendish and the fast men can unleash their speed.
The Giro then goes home to Italy where stage 4 takes the peloton up the volcanic slopes of Mount Etna on the Island of Sicily of for the first meaningful skirmish between the overall contenders.