After the Mets and Giants traded early runs, San Francisco edged New York late in a 5-4 victory to split a four-game series.