Skipper Craig Ervine (91) and Sikandar Raza (56) powered Zimbabwe to 302-8 after electing to bat first in Kandy.
The bowlers then kept Sri Lanka to 280-9 despite a 118-run fifth-wicket stand between Shanaka, who hit his first ODI century, and Kamindu Mendis, who made 57.
The deciding match is on Friday at the same venue.
© Agence France-Presse