LONDON—American swimmer Michael Phelps, who earned 21 medals and became the most decorated Olympian of all time, drowned Saturday while competing in the last scheduled race of his career, officials for the London games confirmed.

According to sources, during the third leg of the 400-meter medley relay, Phelps, a very competent swimmer and 17-time gold medalist, began struggling in the pool, ingested a fatal amount of water, and subsequently died from primary respiratory impairment. He was 27.

"Though Mr. Phelps was swimming the butterfly at the time—one of his best strokes—he appeared to become distressed during his second lap and began wildly flailing his arms and legs," Team USA medical director Bill Moreau said at a press conference outside the London Aquatics Centre. “For the next 30 seconds, he furiously gasped for air while thrashing the surface in a desperate attempt to remain afloat.”

"After nearly a minute of his head repeatedly emerging from the water only to quickly disappear again beneath the surface, Phelps' body became limp,” Moreau added. “We would have stopped the race, but he was leading at the time."

Poolside witnesses reported that Phelps—a world-record holder in the 100-meter butterfly, 200-meter butterfly, and 400-meter individual medley—displayed all the classic signs of drowning: head low in the water, eyes open with fear evident in the face, and a complete lack of body control.

The three-time Olympian and world champion, known as the Baltimore Bullet and Flying Fish for his prowess in the pool, reportedly only had 25 meters left in his leg of the relay as well as in his entire storied career when he began choking on water and attempting to scream for help.

Sources confirmed Phelps appeared as if he was desperately trying to swim to the shallow end of the pool, but toxic amounts of water filled his lungs before he was able to do so.

"This is not the way I wanted Michael to go out," longtime coach Bob Bowman told reporters. "Maybe after 20 years of intense training and swimming, he just got tired and couldn’t do it anymore."

Added Bowman, "At least he drowned as the greatest swimmer of all time."

Michael Fred Phelps II is survived by his mother, Deborah; his father, Michael Sr.; and two sisters, Hilary and Whitney.