Mareczko (Wilier Triestina-Selle) led out the sprint on the left-hand side of the peloton with just under 600m of the relatively flat 167km stage left.
Viviani (Quick-Step Floors) was however quick to grab his wheel and comfortably powered past in the closing metres.
Irishman Sam Bennett (Bora-Hansgrohe) was third with South Africa’s Ryan Gibbons (DiData) taking seventh.
Australia’s Rohan Dennis (BMC), who finished second in yesterday’s short individual time-trial, took over the pink jersey from Tom Dumoulin (Sunweb) after gaining three bonus seconds at the second intermediate sprint.
He now leads the Dutch defending champion by one second, with Belgium’s Victor Campenaerts (Lotto Fix All) a further two seconds adrift.
The day’s first breakaway – consisting of Davide Ballerini (Androni Giocattoli), Campenaerts and Guy Niv (Israel Cycling Academy) – went clear soon after the 11.9km neutral zone.
They were joined by more riders, but Ballerini attacked again and was joined by Lars Bak (Lotto Fix All).
A crash in Acres caused the peloton to split in to two parts and Niv’s teammate Guillaume Boivin took the opportunity to jump across to form a three-rider break in the front.
The trio were caught and passed by Enrico Barbin (Bardiani-CSF) on the day’s major ascent.
Behind, Dennis’ squad led the chase in an effort to haul back the leaders before the day’s second intermediate sprint, a mission that came to fruition shortly after the climb.
This left Dennis in a good position to contest the prime, which came about 61km from the finish. He kicked early and was able to hold off Viviani to become the virtual leader on the road.
Stage three will take the riders over 229km between Be’er Sheva and Eilat.