Frenchman Lafay, 25, was among a group of nine in the breakaway on the final climb of the 170km stage and held off a late surge from Eolo-Kometa's Francesco Gavazzi who finished second with Team DSM's Nikias Arndt third.
"I spent a lot of energy already in the first part of the stage to get into the breakaway," Lafay said. "There were several attempts but the peloton didn't leave much space. Then finally the breakaway went clear.
"Once the gap started to increase I was able to recover some energy. In the finale of the stage, there were several attacks. I attacked in the last few kilometres and saw that no one was following me."
Groupama-FDJ's Attila Valter retained the leader's pink jersey with none of the general classification contenders losing time as they crossed the line in the same group.
"It was a perfect day for me and for the team," Valter said. "Once the break went clear, we tried not to take any risks.
"It's amazing to see all my teammates working for me and it's fantastic to be able to wear the Maglia Rosa for another day."
Ewan was leading the points classification after winning stages five and seven, with the second victory coming on Friday after a well-timed surge at the finish.
However, the 26-year-old Australian never planned to complete the May 8-30 race as he has his sights set on winning sprint stages in the Tour de France starting on June 26.
"I need to do what's best in preparation for the Tour," Ewan said on Friday.
"Unfortunately, sprinters' legs don't recover in the same way that any other riders' do and if I finished the Giro now I would be dying for the next few months."
The 2021 Giro d'Italia continues as the riders tackle the climb from Castel di Sangro to Campo Felice - LIVE, FREE and in HD TONIGHT from 8:05pm AEST on SBS On Demand and 9:15pm AEST on SBS VICELAND.