Nolasco (9-9) held the Mets to two runs, allowing seven hits and a pair of walks while striking out two in recording his third win in three starts.
Ronald Belisario and Paco Rodriguez combined for 1 1/3 scoreless relief innings and Kenley Jansen recorded the final four outs for his 18th save as the National League West-leading Dodgers moved a season-high 18 games over .500 (68-50).
Los Angeles trailed 2-0 until the sixth when they struck for three runs.
Mets center fielder Juan Lagares threw to third on the play, but his throw short-hopped Wilmer Flores and bounced into the Dodgers' dugout, allowing Ellis to score and Gonzalez to reach third.
He then scored the go-ahead run on a Yasiel Puig sacrifice fly.
Nick Punto later added a solo homer for the final margin.
Mejia (1-2) allowed three runs (two earned) on six hits over six innings.
Teacher apologizes for showing sexual image of herself in class
Scarlett Johansson steps out with fiance after pregnancy reveal