Race leader Tadej Pogacar tried to take the stage in the final 2km with a surprising burst in an attempt to win two days in a row.
The Slovene was followed by pink jersey rival Geraint Thomas and caught by the peloton near the line before Merlier claimed the tightest of victories over Milan.
UAE rider Pogacar, in his first Giro, holds the overall lead ahead of Thomas before Tuesday's 190km slog from Acqui Terme to Andora on the Italian Riviera.