Here's what happened when Michael Phelps raced a Great White Shark

Retired competitive swimmer Michael Phelps, the most decorated Olympian of all time with a total of 28 medals, took on a great white shark in a Discovery Channel special on Sunday night.

Did he win?

Phelps vs Shark: Great Gold vs Great White, which helped kick off Discovery Channel's Shark Week programming, found Phelps and a group of scientists working to record the speed of, first, a hammerhead shark and then a great white shark.

"This is something I've been wanting to do for a while," Phelps said of his interest in taking on the challenge.

RELATED: A look at Michael Phelps' career highlights

The team developed a special device to record the sharks' swimming speed. Dubbed a "cutting-edge water vehicle prototype" featuring lightweight carbon fiber, the "pontoon bike" was trailed by bait to entice the shark to follow quickly behind as its speed was measured. First testing a hammerhead, the sea creature's top speed was measured at 15 miles an hour, and it traveled 50 meters in just over 15 seconds.

Compare that to Phelps' speed of just over 5.5 miles an hour when he broke the world record in the butterfly.

"Honestly, my first thought when I saw the shark was, 'There's very little chance for me to beat him,'" Phelps said.

Wearing a monofin to simulate a shark's movements — and to maximize his speed and the volume of water he was able to push with each kick — Phelps swam 50 meters in the ocean off the Bimini coast and came in at 18.7 seconds, with the team comparing his time to those of a hammerhead and a reef shark.

While he didn't beat the hammerhead, which swam the distance in 15.1 seconds, he was able to beat the reef shark by 0.2 seconds, swimming at 6 miles an hour.

Next up: the great white shark, whose top speed was recorded as more than 26 miles per hour (able to swim 100 meters in 36.1 seconds) off the coast of Mossel Bay, South Africa.

Working in Phelps' favor is the fact that sharks can't sustain a high speed and must slow down at times to conserve energy. The team decided to extend the race to 100 meters, given Phelps' ability to sustain top speeds over a long distance, to give him "a swimming chance," as one of the experts put it.

"I've always been an endurance swimmer, and hopefully that will work in my favor," Phelps said.

In addition, he was given a modified monofin in an effort to improve his speed even more. However, the visibility in the South African waters was not nearly as clear as that in Bimini. And the water was a lot colder, at 56 degrees, or 24 degrees colder than the water in an Olympic pool.

"I'm high maintenance when it comes to cold water," Phelps said. "I don't like it."

Making it more challenging, Phelps was wearing a wetsuit that was only 1 millimeter thick. Sharks, meanwhile, are able to raise the temperature of their muscles up to 25 degrees higher than their surroundings.

Read more: Sharks on a Plane: Discovery Sets 'Shark Week' Partnerships With Southwest Airlines and More Brands

By the way, in case you were wondering, Phelps did not race side-by-side with the sharks; rather, images the sharks were displayed alongside Phelps as he swam using CGI technology. Some viewers expressed disappointment on Twitter that he wasn't actually swimming in the water with the shark: "Michael Phelps is racing a CGI shark. The world is yet again a meme," wrote one.

But, noted Dr. Tristan Guttridge, a scientist leading the effort: "Clearly, we can't put Michael in one lane and a shark in the far lane. We have to do simulation. We'll use our speed data that we've (collected) in all our testing."

Meanwhile, Phelps worked on a new stroke as he practiced for the race. "I'm gonna have to swim, and act, like a shark," Phelps said ahead of the race, as he was seen swimming what looked like a sideways butterfly stroke.

RELATED: Michael Phelps Olympic history

Added Guttridge: "This is like the tortoise and the hair, where Michael is the tortoise, steady as he goes, consistently in the race, while the white shark is slow and cruising with bursts of speed."

So who won?

Phelps swam the 100 meters in 38.1 seconds, while the shark did the same length in 36.1 seconds, beating Phelps by two seconds.

At the start of the race, Phelps reached a speed of 8.8 miles an hour, swimming faster than the shark, but then the shark took the lead at the 25-meter mark, and Phelps was unable to overcome the creature's lead.

"Before I dove in, I knew how cold it was going to be, and I knew that for me, as a swimmer, we don't swim in this, and it basically just shocked your entire body," he said. "And I have this little tiny wetsuit on, so it's absolutely freezing."

But Phelps isn't a sore loser: "I think it's impressive to see an animal survive this (cold water) and still have a top speed of 25 miles an hour."