NEW YORK -- Union Rags picked up right where I'll Have Another left off, coming from behind to catch a Bob Baffert-trained horse at the finish in a Triple Crown race.

In Saturday's Belmont Stakes, it was another photo finish decided by a neck. Just like the Preakness.

The 3-year-old bay colt barreled through a slim opening on the rail to edge Paynter, dealing Baffert, jockey Mike Smith and owner Ahmed Zayat a third loss in this year's Triple Crown series.

"We needed every bit of the mile and a half," winning trainer Michael Matz said.

I'll Have Another won the Kentucky Derby and Preakness with stirring stretch drives over Baffert's Bodemeister. But the champion stunned the racing world Friday when he was scratched from the Belmont and retired due to a tendon injury, relinquishing a shot at the first Triple Crown sweep since 1978 and only the 12th ever.

His absence opened up the race for Union Rags, who finished a troubled seventh in the Derby after a bumpy start.

Union Rags skipped the Preakness and because of the Derby problems switched jockeys for the Belmont -- from Julien Leparoux to John Velazquez, who picked up his second Belmont victory; he won in 2007 with filly Rags to Riches.

"I have to give it to the horse. He did it all for me. He just worked so unbelievable and I was just hoping he could put that work into today's race and he did," said Velazquez, who will enter racing's Hall of Fame in August. "I was very proud of him."

A crowd of 85,811, cheered as Paynter and Union Rags furiously battled down the stretch, with Union Rags barely catching the front-runner in the second straight photo finish to decide a Triple Crown race this year.

"Is there a Triple Crown for seconds?" Baffert said. "I really felt like I was going to win the Belmont. It was snatched away again."

Zayat was just as bummed, calling it "a heartbreaking defeat."

"He ran his guts out," he said, referring to Paynter, who was making just his fourth career start. "I'm very disappointed we opened the rail for (Union Rags)."

Jockey Mike Smith took the blame.

Union Rags, owned by Chadds Ford Stable's Phyllis Wyeth, took the Belmont Stakes in a photo finish on Saturday. Anthony Gruppuso/US Presswire

"I'm an old veteran, you know," he said. "They're not supposed to get through on the fence on me, and he did. I dropped the ball. My fault."

Union Rags was along the inside in the middle of the pack until it was time to make a move for the lead, and that's when Velazquez guided him to the inside of the front-running Paynter. Turning for home, Union Rags was full of run, but needed an opening. Velazquez had no room to swing outside, so he focused on finding a hole along the rail. Suddenly, a sliver appeared when Paynter slid over just enough to let Union Rags through in the final sixteenth of a mile. And then it was a charge to the finish line.

They raced head-to-head, with both jockeys furiously whipping their horses in the shadow of the wire. Union Rags stuck a neck in front at the end and gave fans a thrilling finish that was certainly reminiscent of the sidelined I'll Have Another.

"He jumped right in there and before I could do anything about it, it was too late to stop him," said Smith, the 46-year-old Hall of Famer who was aboard Bodemeister in the two earlier defeats. "I certainly didn't want to let the stewards decide the outcome of the race."

The win also signaled a change of fortune for Union Rags. At the Kentucky Derby, where he was the second choice in betting, he was knocked around by Dullahan coming out of the starting gate and was trapped on the inside, leading Matz to make the jockey change.

In the Florida Derby, he got stuck in traffic and broke free too late, ending up third. As the even-money favorite in last year's Breeders' Cup Juvenile, Union Rags got forced wide for most of the race before closing the gap while running erratically and losing by a head.

"We always thought this horse had Triple Crown potential," Matz said. "He had trouble in his second race and his third race. I do really think that this horse, when he has a clean trip and can show himself, is one of the best 3-year-olds in this crop. Whether he could have done something against I'll Have Another, I don't know, but it sure would have been fun to see."

Union Rags, the 5-2 second choice, ran the 1½ miles in 2:30.42. The colt owned by Phyllis Wyeth returned $7.50, $4.20 and $3.40. Paynter, who sat out the Derby and Preakness, paid $5.10 and $3.90. Atigun was another 1 3/4 lengths back in third and paid $10.60 to show. He also skipped the first two legs of the Triple Crown.

"It was my dream and he made it come true," said Wyeth, wheelchair-bound as the result of a 1962 car accident in which she broke her neck. "Nobody would have gotten through on the rail other than Johnny. That was unbelievable. He just said, 'Move over, I'm coming.' He believed in the horse and Michael got him there."

Street Life was fourth, followed by Five Sixteen, Unstoppable U, Dullahan, My Adonis, Ravelo's Boy and Optimizer. Guyana Star Dweej trailed badly and was eased in the stretch by jockey Kent Desormeaux.

Dullahan was the slight favorite by virtue of the more than $200,000 bet on him to win.

Before the race, I'll Have Another, with jockey Mario Gutierrez aboard, walked into the winner's circle for a tribute to the newly retired champion. Trainer Doug O'Neill removed the chestnut colt's saddle for the last time as his barn staff hugged each other and the crowd cheered in a poignant salute.

"I wish I can be unsaddling him in the winner's circle after a win," O'Neill said. "He was a once in a lifetime, heroic horse."