Dimension Data's Cavendish, attempting to prove his fitness ahead of the Tour de France after being sidelined for nearly three months, was caught behind one of multiple crashes towards the end of the 169.9-kilometre stage.
His lead-out man Mark Renshaw avoided the pile-up, that saw stage one winner Sam Bennett hit the deck, and finished third as Orica-Scott's Luka Mezgec took victory.
Tour of Slovenia
Majka outlasts Visconti to take stage three in Slovenia
Renshaw, himself having endured an injury-hit year, told his team's website: "Once we entered the finish circuit, it got really chaotic with riders crashing in almost every corner due to the slippery roads.
"Our original plan was to sprint for Cavendish, but with about one kilometre to go, (team-mate Bernhard) Eisel told me on the radio to try and go for it myself instead. Unfortunately, when Mezgec jumped with 500 metres to go, I just couldn't get in the wheel of him."
Cavendish is racing in his first event since March after being diagnosed with glandular fever, caused by the Epstein-Barr virus.
The 32-year-old has two more stages to help build his fitness, while he is scheduled to race in the British Championships on the Isle of Man on June 25.
The Tour de France starts in Dusseldorf on July 1 and concludes in Paris on July 23.