Viviani came up trumps in the messy sprint in Genova at the conclusion of the 177km stage. The Italian held off Moreno Hofland (LottoNL-Jumbo) and stage favourite Andre Greipel (Lotto-Soudal) to claim his first Grand Tour stage victory.
Matthews finished seventh on the stage to claim the Maglia Rosa from Orica-GreenEDGE team-mate Simon Gerrans who was in pink after the team won the opening time trial.
"It was a really special time for me to wear the Maglia Rosa last year, and to wear it for the second time is even sweeter," said Matthews.
"It was team work yesterday that got me where I am today, so I have to thank my team-mates for this magical feeling.
"It was a pretty technical final and really fast too," continued Matthews. "You had to be in good position in the last kilometre and we were maybe a little far back. We made the decision to go early from the last corner but maybe it was a little bit too early."
Alberto Contador retains his position as the best general classification contender, sitting seven seconds behind Matthews and three other Orica-GreenEDGE riders. In addition to winning the stage, Sky managed to protect its team leader Richie Porte with the Australian still trailing Contador by 20 seconds.
"This year I'm with a new team and with a new motivation," said stage winner Viviani. "We are here to do a good GC with Richie and to win the Giro with him. That means I don't have as many guys for the final, but as you saw today the guys did a perfect job for Richie and also for me. In the last 3km Salvatore Puccio and Bernie (Eisel) were there for me. They did incredible work."
Five eager riders - Bert-Jan Lindeman (LottoNL-Jumbo), Eugert Zhupa (Southeast), Giacomo Berlato (Nippo-Vini Fantini), Lukasz Owsian (CCC Sprandi Polkowice) and Marco Frapporti (Androni) - formed the first breakaway of the tour, with the group establishing an eight minute advantage just 25km into the stage.
With the maglia rosa to protect, Orica-GreenEDGE was present at the front of the peloton, with Trek Factory Racing sharing the load to reduce the leaders's advantage.
The breakaway had five minutes in hand as they approached the sole climb of the stage, the category four Prato Zanino with 60km to go.
A chain issue saw Frapporti lose contact with his breakaway companions who attacked on the climb as the Italian struggled with his bike. Lindeman was the first to crest the climb, earning himself the King of the Mountains jersey in the process.
It was Contador’s Tinkoff-Saxo team who led the peloton over the top of the climb, with their pace-setting shedding riders off the back and reducing the leader’s advantage.
With 35km to go the lead was down to two minutes, with Giant-Alpecin, Trek Factory Racing and Lotto-Soudal controlling the pace as they hit the outskirts of Genova. The pace was disrupted 10 kilometres later with a crash in the back of the peloton with Australian champion Heinrich Haussler the first to hit the deck.
Other casualties included Haussler’s IAM Cycling team-mate Sylvain Chavanel, Orica-GreenEDGE’s Michael Hepburn and BMC’s Darwin Atapuma.
The breakaway hit the 9.5km finishing circuit for the first time with a slim 47 second advantage. It was Tinkoff-Saxo who was still on the front of the peloton, keeping Contador out of trouble as last year’s Giro champion Nairo Quintana’s brother Dayer tasted the tarmac.
It was a case of deja-vu for Haussler who found himself back on the ground with 12.4km to go, with this second crash splintering the peloton.
Owsian, the last surviving member of the breakaway, was caught with 11km to go, as Tinkoff-Saxo lead the peloton across the finish line to get the bell, with a large group caught out by the crash chasing the peloton.
Tinkoff-Saxo, Team Sky and Astana sat at the front on the race through the final circuit, with Sky taking over duties with three kilometres to go.
The sprinters made themselves known in the final kilometre, with the slight uphill slog for the finish making for a messy finale.
Greipel launched early but Viviani had enough in him to overcome the German and hold off Hofland.
Stage 3 is a technical and punchy 136km from Rapallo to Sestri Levante, perfect for a breakaway to succeed or a reduced sprint. The profile means Matthews could be in the mix for the victory.
Stage 2: 177km, Albenga - Genoa
1 Elia Viviani (ITA) Sky 4hr 13min 18sec
2 Moreno Hofland (NED) LottoNL-Jumbo
3 Andre Greipel (GER) Lotto Soudal
4 Luka Mezgec (SLO) Giant-Alpecin
5 Alessandro Petacchi (ITA) Southeast
6 Giacomo Nizzolo (ITA) Trek Factory Racing
7 Michael Matthews (AUS) Orica-GreenEDGE
8 Davide Appollonio (ITA) Androni-Sidermec
9 Daniele Colli (ITA) Nippo-Vini Fantini
10 Paolo Tiralongo (ITA) Astana
1 Michael Matthews (AUS) Orica-GreenEDGE
2 Simon Gerrans (AUS) Orica-GreenEDGE
3 Simon Clarke (AUS) Orica-GreenEDGE
4 Esteban Chaves (COL) Orica-GreenEDGE
5 Roman Kreuziger (CZE) Tinkoff-Saxo 0:00:07
6 Alberto Contador (ESP) Tinkoff-Saxo
7 Michael Rogers (AUS) Tinkoff-Saxo
8 Manuele Boaro (ITA) Tinkoff-Saxo
9 Ivan Rovny (RUS) Tinkoff-Saxo
10 Paolo Tiralongo (ITA) Astana 0:00:13