Ulissi, 24, attacked in the final 100m of the second of successive Cat.4 climbs that concluded the 203km stage five from Taranto.
Australian Michael Matthews (Orica-GreenEdge) finished sixth to retain the leader's pink jersey by 15 seconds over team-mate Pieter Weening.
Veteran Evans is one second further back in third place and four seconds ahead of Omega Pharma-Quick Step's Rigoberto Uran, who took fourth place in a thrilling finale.
Race favourites Joaquim Rodriguez (Katusha) and Nairo Quintana (Movistar) both finished in the top ten while there was a strong sixth place for Norway's Edvald Boasson Hagen (Team Sky).
A sudden shower made the winding descent ahead of the final climb a treacherous affair, with numerous riders - including Astana pair Enrico Gasparotto and Mikel Landa, and Fabio Felline of Trek - hitting the deck on the succession of hairpin bends.
Italy's Gianluca Brambilla (Omega Pharma-Quick Step) threw caution to the wind, breaking clear on the descent to build up a lead of 35 seconds with just 5km remaining.
Europcar pair Davide Malacarne and Pierre Rolland both put in futile solo digs on the final Cat.4 climb before Brambilla was swept up by the Katusha-led pack inside the final 2km.
Nicolas Roche (Tinkoff-Saxo) was the first of the GC men to have a pop but the Irishman was pegged back by Rodriguez inside the final kilometre.
Matthews - who had targeted this stage for the victory - was in a good position as Ulissi launched from the wheel of his Polish team-mate Przemyslaw Niemiec. Ulissi powered through on the inside of Evans and the energetic Arredondo to take his second career win in the Giro, three years after his maiden scalp.
Tinkoff-Saxo's Rafal Majka (fifth) showed promising form while Dutch youngster Wilco Kelderman (Belkin) finished eighth ahead of local boy Domenico Pozzovivo (Ag2R-La Mondiale), who had been caught behind an earlier crash on the first ascent of the climb to Viggiano.
11-MAN GROUP: Sprinters Elia Viviani (Cannondale), Ben Swift (Team Sky) and Tyler Farrar were key components of an early break, the trio no doubt eying the red jersey points at the intermediate sprint. They were joined by Farrar's Garmin-Sharp team-mate Fabian Wegmann, Miguel Angel Rubiano (Colombia), Tony Hurel and Bjorn Thurau (Europcar), Marco Frapporti (Androni Giocattoli), Yonathan Monsalve (Neri Sottoli), Kenny Dehaes and Tosh Van der Sande (Lotto-Belisol).
The break built up a maximum lead of around six minutes while Viviani took maximum points in the intermediate sprint to move him above stage four winner Nacer Bouhanni in the battle for the red jersey. Rubiano took the maximum seven points over the Cat.3 climb of Valico de Serra san Cherico (66km from the finish) to move within three points of Dutchman Maarten Tjallingii (Belkin) in the blue jersey competition.
Thurau was the last rider of the breakaway group to be caught by the pack some 14km from the finish near the summit of the first climb to Viggiano.
BIG WINNERS OF THE DAY: Ulissi reminded the world of his promise with a superb win while Evans showed that he's a true prospect for GC despite his advanced age. But by retaining the pink jersey for a fourth day, Matthews set a record for Australia, outdoing compatriot Richie Porte's run from 2010.
BIG LOSERS OF THE DAY: Astana saw two of their riders - Landa and Gasparotto - hit the deck on the wet descent near the finish and morale must be low for the Kazakh team despite two men - Scarponi and Fabio Aru - in the top ten on GC. Ag2R's Pozzovivo, who hails from the intermediate sprint town of Montalbano Jonico, also had a tricky day after being caught behind a crash. The diminutive Italian recovered to take ninth place, but would have liked to contest the win in his native region of Basilicata.
KEY MOMENT: The sudden downpour changed the dynamic of the stage and made the decisive descent rather sketchy. None of the GC riders dared take a risk but they were all present and correct in the final climb.
TALKING POINT: Can Cadel Evans win the Giro? So far, so good for the Australian, who's been in the thick of the action in all the stages and almost conjured up a stage win in Viggiano.
COMING UP: After a lumpy start, Thursday's long 247km stage six skirts Naples before an uphill finish at Montecassino with a 5% gradient. The finish commemorates the site of a large battle in 1944. Expect a similarly explosive finish, with the likes of Evans, Rodriguez, Uran and Quintana all in with a shout.
1. Diego Ulissi (Italy / Lampre) 5:12:39"
2. Cadel Evans (Australia / BMC Racing) +1"
3. Julian Arredondo (Colombia / Trek)
4. Rigoberto Uran (Colombia / Omega Pharma - Quick-Step)
5. Rafal Majka (Poland / Tinkoff - Saxo)
6. Michael Matthews (Australia / Orica)
7. Joaquim Rodriguez (Spain / Katusha)
8. Wilco Kelderman (Netherlands / Belkin)
9. Domenico Pozzovivo (Italy / AG2R)
10. Nairo Quintana (Colombia / Movistar)
- Sports & Recreation
- Joaquim Rodriguez
- Rigoberto Uran
- Nairo Quintana
- Cadel Evans
- Enrico Gasparotto