Gilbert (Quick-Step Floors) outkicked Kiwi Patrick Bevan (Cannondale-Drapac) and Anthony Roux (FDJ) at the end of the 172.7km stage around Cham.
"It was very nervous out there, because the peloton let the escapees open up a big gap and then started to chase hard, but the margin still wasn't coming down,” Gilbert said.
“So it was no surprise that we had some crashes in the peloton, even I was involved in one five kilometres from the last climb and had to make a big effort to return in the pack, which brought me to the limit.”
A five rider break got the stage started with Aqua Blue Sport's Lasse Norman Hansen making the most of it to take the mountains classification and Nick Dougall (Dimension Data) doing the same in the points category.
The crash which stalled Dennis came shortly after the break was caught with 25km to go leaving him almost 10 minutes adrift by stage end.
Second overall before the stage, Küng finished safely in the peloton to step on the podium as the new overall leader with a single second margin over the Sunweb duo of Australian Michael Matthews and Giro d'Italian champion Tom Dumoulin.
"It was really unfortunate that Rohan Dennis crashed," Küng said. "To take the jersey like that never feels good especially when it is a teammate.
"I will definitely try to enjoy my day in yellow tomorrow especially as we are racing to our capital city, Bern."
Stage 3 takes the peloton on a hilly 159.3km from Menziken to Bern.