The 20-times Grand Slam winner has produced a series of lacklustre performances in Shanghai, his first tournament since suffering a shock fourth-round defeat by John Millman at the U.S. Open last month.
Yet he made an aggressive start against Nishikori to take a 4-1 lead in the opening set.
Federer held off a late charge from the Japanese to take the opener before recovering from a 4-1 deficit in the second set tiebreak to seal victory.
The 37-year-old will next face Croatian power-hitter Borna Coric, who dumped Australia's Matthew Ebden out of the tournament 7-5 6-4. Coric beat Federer in the Halle final in their last meeting earlier this year.
Earlier in the day, three-time Shanghai champion Novak Djokovic extended his winning streak to 16 matches after beating South African Kevin Anderson 7-6(1) 6-3, edging the Serb closer to the world number two ranking.
Djokovic, who has won the last two Grand Slams, at Wimbledon and the U.S. Open, is currently world number three, but could move up a spot if he books a place in Sunday's final.
The 31-year-old Serb saved a set point against Anderson in an intense opener, before taking control in the tiebreak.
Second seed Djokovic broke early to take a 2-0 lead when his South African opponent found the net with a backhand.
Djokovic held the advantage to seal the victory and set up a semi-final clash with Germany's Alexander Zverev, who became the fifth singles player to qualify for November's ATP Finals with a 6-4 6-4 win over Kyle Edmund.
"He (Zverev) has improved a lot, and he has established himself as a top player," Djokovic said.
"I think, quite similar in style of play to today's match. Kevin is a big server, big hitter from the back of the court, really aggressive, tall. Sascha (Zverev) is similar to that."
Alexander Zverev of Germany celebrates a point against Kyle Edmund of Great Britain during the 2018 Rolex Shanghai Masters Men's Singles - Quarterfinals match at Qi Zhong Tennis Centre on October 12, 2018 in Shanghai, China.
Image credit: Getty Images
Zverev became the first German to seal a spot in successive years in the season-ending event since six-times Grand Slam winner Boris Becker (1994-96).
"It's great to finally officially make it and again be a part of the best eight, which is an elite group," the 21-year-old said.
"It's close to, or it's maybe equal to winning a Grand Slam, and I think other players will tell you the same thing, because just to be there, you obviously play well throughout the whole year." (Reporting by Nivedita Balu in Bengaluru Editing by Toby Davis)