Dimension Data rider Cavendish nonetheless maintained his overall race lead by five seconds from Katusha's Kristoff with Sacha Modolo third at 14sec.
"It was close and Cavendish is very strong, so I'm happy with this victory," said Kristoff.
The shallow climb to the finish was ideal for Kristoff despite losing two of his lead-out train, Andrea Guardini and Soren Kragh Andersen, to a crash on the home straight.
“These kind of hard sprints suit me really well and I knew I had a chance today, but of course, after yesterday's stage I was not sure I would be able to do it," he said.
The incident came from 300 metres out as several riders jostled for sprint position and rode into an un-fenced section of a road divider.
For the second day, the 135km stage was around the campus of the University of Qatar taking in the 15.3km circuit of the artificial island The Pearl, on a course prepared for the world road race championships in October.
Kristoff had managed to sneak into a breakaway group that stretched to a 1min 20sec lead running into a headwind before Cavendish galvanised the peloton to reel in the group of twenty riders.
There was a second attempted breakaway by Preben Van Hecke (Topsport Vlaanderen-Baloise) and Gatis Smukulis (Katusha), who were also reeled in.
The third stage will be a 11.4km individual time trial on the Lusail motor-racing circuit, north of Doha.