Ibanez hit a 1-0 pitch into the seats in the ninth, setting off a raucous celebration in what had been a demoralized Yankee Stadium crowd.
Ibanez at first didn't know who he was hitting for and was a bit startled when Eduardo Nunez told him.
"Alex is one of the best hitters of all time, and he still is," Ibanez said. "I mean, he's one of the greatest players in the history of the game. So for a minute I just thought something was going on, I didn't know what was happening, and then I just tried to put it behind me and get a good pitch to hit."
After their 10-game July lead was cut to zero in early September, the Yankees repelled every Orioles charge. The teams were tied 10 times in the final month but New York ended up atop the division.
New York won the opener in Baltimore by scoring five runs in the ninth off Johnson, who had 51 saves in the regular season. The Orioles won Game 2 and rode Miguel Gonzalez's pretty performance to a 2-1 lead in the ninth.
"Jimmy is a big-hearted, talented guy that believe me, we'd be at home watching without people like Jim Johnson," Orioles manager Buck Showalter said. "He's a special guy. We're real proud of him, and you'll see him again tomorrow night, I hope."
The Yankees limited Baltimore to one hit after 20-year-old Manny Machado homered in the fifth. Ryan Flaherty homered earlier for the Orioles.
Robert Andino was doubled off second after leading off the Baltimore ninth with a single and advancing on a sacrifice.
Boone Logan got one out in relief of Hiroki Kuroda, who gave up two solo homers in 8 1-3 innings. Closer Rafael Soriano pitched 1 1-3 innings and David Robertson went two, finishing off his outing by bumping into and tagging Andino to end the top of the 12th.