Federer, who has now won the Wimbledon warm-up event on grass six times, needed to dig deep for his 77th career title and extend his head-to-head with Youzhny to an impressive 15-0.
"I have won a lot in my career but not recently," said Federer, whose last tournament win was in August 2012 in Cincinnati. "I am happy it worked for me today.
"I was satisfied with my game in the past 10 months. Maybe people thought I was playing badly. That was not the case. I was playing well but when it mattered the others were just better. Today it worked well," he said in a courtside interview.
The 31-year-old won three break points in the first game but Youzhny's powerful serve got the world number 29 out of early trouble.
The Russian, who defeated three seeded players en route to the final, held serve and matched Federer's skill on grass with hammering groundstrokes.
Federer, who has now beaten Youzhny five times at Halle since 2002, saved a set point at 5-6 but conceded another in the tiebreak for the Russian to take the lead with a well-placed volley.
Federer improved his first serve and refused to buckle, finally getting his first break when Youzhny double-faulted for 5-3 before he served out the second set.
The Swiss patiently waited for his next break opportunity and got it after a sizzling exchange of groundstrokes, Federer going 4-3 up and holding serve to clinch his maiden 2013 title after two hours and two minutes.
"He just played better," said Youzhny, whose battling spirit won him a lot of crowd support. "In fact he has been playing better all my life."
Wimbledon starts a week on Monday.