BALTIMORE — It wasn’t a two-horse race after all. At least not at the end.

Cloud Computing shocked the favored Always Dreaming and primary rival Classic Empire, winning the 142nd Preakness Stakes at Pimlico Race Course on Saturday.

Just the third non-Kentucky Derby runner to win the second leg of the Triple Crown since 2000, Chad Brown’s colt edged Classic Empire in a photo finish, covering the 1 3/16 miles in 1 minute, 55 seconds. He was a 12-1 choice on the morning line.

Always Dreaming and Classic Empire dueled early, with Always Dreaming falling off as the horse turned down the stretch.

Cloud Computing hadn’t raced in six weeks, having skipped the Kentucky Derby despite qualifying. That decision paid off for Brown, last year’s Eclipse winner as top trainer. He won his first Preakness with his first entrant in the race.

Javier Castellano, riding Cloud Computing, appeared to wait for Always Dreaming, who broke quickly to the lead, to lag before making his move to challenge Classic Empire over the final furlong.

Always Dreaming faded to finish eighth out of 10 horses.

Cloud Computing won by a head and paid $28.80. Classic Empire finished second followed by Senior Investment.

Brown admitted that he targeted Always Dreaming and Classic Empire – clearly the most talented members of the 3-year-old class coming into this race – by holding Cloud Computing out of the Derby.

“Certainly I’m not going to dispute the fact that I brought a fresh horse as part of our strategy,” he said. “Our house is very talented, too. Classic Empire and Always Dreaming are two outstanding horses and our strategy was, ‘If we are going to ever beat them, let’s take them on two week’s rest when we have six, and it worked.”