Federer, who took time off while his wife gave birth to twin girls, took a set to find his range and then the top-ranked Swiss star put away the low-ranked Niemeyer.
The 33-year-old Niemeyer, whose ranking has tumbled to 487th, plans to retire at the end of this season.
Earlier, Andy Murray - also playing his first match since Wimbledon - beat France’s Jeremy Chardy 6-4, 6-2.
Murray lost to Andy Roddick in the Wimbledon semifinals five weeks ago, and he had enough form to get past Chardy. Murray converted three of eight break chances, while Chardy missed all 10 of his.
"I feel better now I’ve got through the first one, because you lose your rhythm a bit," said the third-seeded Murray. "I didn’t really have more than six or seven days off without playing a match for a long time."
Murray is off to the best start of his career with a 46-7 record, winning four tournaments this year.
With Rafael Nadal struggling on sore knees, Murray can overtake the Spaniard for the No. 2 ranking if he wins the tournament. Murray also could attain No. 2 if he reaches the final and Nadal loses in the semifinals.
"I’ve been asked about it a lot so, it’s impossible not to think about it. But when I’m playing my match, it’s the furthest thing from my mind," Murray said of the rankings.
Nadal played doubles on Tuesday. He’s scheduled to play singles on Wednesday, the first since he lost in the fourth round of the French Open and withdrew from Wimbledon because of tendinitis in his knees.
Following a first-round bye into the second round, Murray will next face the winner between Juan Carlos Ferrero and 13th-seeded Gael Monfils. Ferrero advanced by defeating Lleyton Hewitt 6-1, 6-4 in a match of former No. 1s.
The Spaniard improved to 4-6 in career matches against Hewitt. Ferrero needed to get through two qualifiers to play in the tournament.
Last year, Hewitt missed the Rogers Cup because of hip surgery. He said he injured a leg last week and wasn’t able to train for several days. He said it restricted his movement on the court, but he hopes to be back on form before the U.S. Open at the end of the month.
Joining Murray in the third round were fourth-ranked Novak Djokovic, who trailed 3-0 in the first set before rallying for a 6-4, 7-6 (6) victory over Canadian Peter Polansky, and eighth-seeded Nikolay Davydenko, who overcame Paul-Henri Mathieu of France 7-6 (4), 7-6 (2) in two hours.