Italian Valerio Conti, riding for UAE Emirates, kept the overall leader's pink jersey on the eve of the first day in the Alps on Thursday.
The 24-year-old Ewan of Lotto-Soudal claimed his second stage win of this year's race, four days after winning stage eight at Pesaro.
"A longer stage today suited me a bit better than yesterday with the other sprinters having sore legs," said Ewan after over five hours racing in the final flat stage before the challenging hilly terrain.
"It came down to the team, who did a great job over the final kilometres. I knew that, riding into a headwind, you really need to time it perfectly."
Three Italians who have been consistently active in breakaways - Marco Frapporti, Mirco Maestri and Damiano Cima - once again led a long escape in the 221km stage raced entirely in sunshine.
The trio were caught 25km from Novi Ligure, in northwestern Italy.
In the sprint, Australian Ewan chased down German champion Pascal Ackermann, who had to settle for third, a day after crashing.
Demare of Groupama-FDJ, the winner of the crash-marred 10th stage at Modena, snatched second place for a boost to overtake Ackermann at the top of the points standings.
"I think Pascal (Ackermann) went too early. I waited and it worked for me," said Ewan, who also won a stage in the 2017 Giro.
"He (Ackermann) had a good lead out so it was a good wheel to sit on. I timed it right.
"I always considered myself one of the top sprinters. Two stage wins prove that I am really one of them."
Italian Elia Viviani, winner of four stages last year, once again fell short, finishing fourth in the sprint, and announced he was withdrawing from the race before the mountains.
"I'm disappointed. My Giro ends today, I have to pull the plug," said the Olympic omnium champion.
"Something wasn't working. If I knew what was wrong I would have won today. I'm lacking explosiveness.
"I probably have to take a moment with my head and recover my mental energy.
"I will try to find the power I had before arriving here and I showed in the first stages."
Ewan is also expected to withdraw from the race before the mountains to prepare for the Tour de France.
Conti, meanwhile, holds a 1:50 advantage on Slovenian Team Jumbo rider Primoz Roglic with France's Nans Peters of AG2R La Mondiale third at 2:21.
"Tomorrow it'll be harder to keep the jersey because the main climb is a hard one," said Conti.
"But I want to keep the Maglia Rosa (pink jersey) tomorrow also.”
Thursday's 12th stage covers 156km between Cuneo and Pinerolo in the Italian Alps, the scene of Fausto Coppi's mythical long-range attack in 1949.
The route is not the same as 70 years ago with riders hitting the first top category climb of this year's race.
The Montoso climb covers 8.8km with a 9.5% gradient, with the summit 32km from the finish line, before another little "wall" awaits competitors just two kilometres from the finish.
Results after Wednesday's 11th stage of the Giro d'Italia, a 221km run from Carpi to Novi Ligure:
1. Caleb Ewan (AUS/LOT) 5hr 17min 26sec, 2. Arnaud Demare (FRA/FDJ)
same time, 3. Pascal Ackermann (GER/BOR) s.t., 4. Elia Viviani (ITA/DEC)
s.t., 5. Davide Cimolai (ITA/ICA) s.t., 6. Simone Consonni (ITA/UAE)
s.t., 7. Ryan Gibbons (RSA/DDT) s.t., 8. Giacomo Nizzolo (ITA/DDT) s.t..
9. Jakub Mareczko (ITA/CCC) s.t., 10. Sean Bennett (USA/EF1) s.t, 11.
Juan José Lobato (ESP/NIP) s.t., 12. Marco Canola (ITA/NIP) s.t., 13.
Manuel Belletti (ITA/AND) s.t., 14. Giovanni Lonardi (ITA/NIP) s.t., 15.
Enrico Barbin (ITA/BAR) s.t.
1. Valerio Conti (ITA/UAE Emirates) 45hr 02min 05sec, 2. Primoz
Roglic (SLO/JUM) at 1min 50sec, 3. Nans Peters (FRA/ALM) 2:21, 4. Jose
Joaquin Rojas (ESP/MOV) 2:33, 5. Fausto Masnada (ITA/AND) 2:36, 6.
Andrey Amador (CRC/MOV) 2:39, 7. Amaro Antunes (POR/CCC) 3:05, 8.
Valentin Madouas (FRA/FDJ) 3:27, 9. Giovanni Carboni (ITA/BAR) 3:30, 10.
Pello Bilbao (ESP/AST) 3:32, 11. Vincenzo Nibali (ITA/BAH) 3:34, 12.
Bauke Mollema (NED/TRE) 3:45, 13. Pieter Serry(BEL/DEC) 3:47, 14. Bob
Jungels (LUX/DEC) 4:08, 15. Mattia Cattaneo (ITA/AND) 4:34
17. Davide Formolo (ITA/BOR) 4:42, 18. Rafal Majka (POL/BOR) 4:43,
20. Richard Carapaz (ECU/MOV) 5:06, 22. Ilnur Zakarin (RUS/KAT) 5:22,
24. Simon Yates (GBR/MIT) 5:36, 26. Pavel Sivakov (RUS/INE) 6:01, 27.
Miguel Angel Lopez (COL/AST) 6:19, 28. Esteban Chaves (COL/MIT) 6:20,
30. Mikel Landa (ESP/MOV) 6:42, 31. Tao Geoghegan Hart (GBR/INE) 6:58,
115. Arnaud Demare (FRA/FDJ) 44:08, 117. Caleb Ewan (AUS/LOT) 45:47,
162. Sho Hatsuyama (JPN/NIP) 1hr 38min 12sec