Gleyber Torres homered for New York in the fourth, but neither team managed a hit in extra innings until Trevino came off the bench and delivered with two outs and runners at second and third.
Batting for fellow catcher Kyle Higashioka, Trevino lined a 1-1 pitch from Alec Mills (0-1) over shortstop to give the major league-leading Yankees (42-16) their ninth victory in 10 games.
Jason Heyward hit his first home run this season for the Cubs, making their first visit to Yankee Stadium since April 2014. Chicago (23-34) dropped its fourth straight.
The teams matched Tampa Bay and Baltimore on May 20 for the longest game in the majors this season by innings.
Luis Severino struck out 10, including five of his first six batters, and provided six innings of one-run ball to steady a strong Yankees rotation coming off three uncharacteristically rugged outings in Minnesota.
Severino raised his arms and clapped into his glove when center fielder Aaron Judge saved at least one and probably two runs with a diving catch to end the third.
Moments earlier, Torres was positioned perfectly in an infield shift to throw out a runner at the plate.
Yankees first baseman Anthony Rizzo was 0 for 4 in his first game against the Cubs since they traded him to New York last July. He also walked and was hit by a pitch.
Yankees reliever Clarke Schmidt was pumped up after getting double plays to end each of his two scoreless extra innings.
Ron Marinaccio (1-0) worked a scoreless inning for his first major league win.
Even with the automatic runner on second base to start every extra inning, neither team was able to break through until the 13th as Yankees fans grew restless. The Cubs didn’t muster a hit after the ninth.
Wade Miley was activated from the injured list to start for the Cubs but didn’t last long. He threw three shutout innings, then exited with left shoulder soreness. The left-hander had been sidelined since May 26 with a shoulder strain after missing the first five weeks this season with elbow inflammation.
Daniel Norris replaced Miley in the fourth and gave up Torres’ 11th home run on his first pitch.
Heyward connected leading off the fifth, an opposite-field shot to left for his first home run since Sept. 8 last year.
Yankees reliever Clay Holmes worked the ninth, extending his shutout streak to 28 innings — the longest for New York since Mariano Rivera finished the 1999 season with 30 2/3 consecutive scoreless innings.
Cubs rookie Christopher Morel had two more hits and has reached base safely in his first 22 major league games.