"Nazi Attack on America," a documentary premiering Wednesday on PBS, shows how close the Nazis came to bringing World War II to America's shores — but just as importantly, it shows how ocean explorers helped raise a Navy captain from humiliation to hero status.

"This really brings closure on a story that began a month before I was born, 73 years ago," Robert Ballard, the oceanographer who rediscovered the Titanic 30 years ago, says at a crucial point in the hourlong show. Ballard is a key player in the story of a reputation's restoration.

The story begins in 1942 with the U-boats — the fleet of German submarines that terrorized ship traffic between the United States and Europe. When America entered World War II, the Nazis launched "Operation Drumbeat," an ambitious plan that used U-boats to drop off spies on the U.S. East Coast and attack shipping in the western Atlantic and the Gulf of Mexico.

Hundreds of ships were sunk. Millions of tons of cargo shipments were intercepted. More than 5,000 lives were lost. But at the time, few Americans knew about the operation or how successful it was, Ballard told NBC News. "Here I was in the Navy for 30 years, and I had never heard about Operation Drumbeat," he said.

Ballard and his team at the Ocean Exploration Trust decided to focus on Operation Drumbeat for a TV documentary produced by Nova and National Geographic. They went to the scene of one of the operation's most notorious episodes: the July 30, 1942, sinking of the Robert E. Lee, a passenger freighter with 407 people aboard, in the Gulf of Mexico about 45 miles off the Louisiana coast.

The fate of U-166

The Robert E. Lee was sunk by a single torpedo from U-166, one of the Nazis' most advanced submarines. But after the attack, the U-166 became prey rather than predator: The USS PC-566, a sub chaser that was escorting the Robert E. Lee, went after the U-boat under the command of a relatively inexperienced captain, Herbert G. Claudius.

The crew dropped depth charges to target the U-166, but the U-boat never surfaced. Eventually, an oil slick was seen rising to the sea's surface. Claudius declared that the sub was sunk, and the ship's crew turned their attention to rescuing the Robert E. Lee's passengers.

These German U-boats were put on display for Admiral Miklos Horthy, the regent of the Kingdom of Hungary and a guest of Nazi leader Adolf Hitler. Courtesy of Everett Historical

End of story? Hardly. Days later, there was another sub sighting in the gulf, about 140 miles away. This time, a depth charge was dropped from the air. No U-boat ever surfaced, but the Navy assumed it was the U-166. Claudius' superiors determined that he had botched the earlier operation and let the U-boat get away. They literally gave Claudius an "F" on his report and ordered him back to anti-submarine warfare school.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"That's pretty humiliating," Ballard said.

That's how the story stood for decades after the war. Then, in 2001, a petroleum survey picked up evidence of a wrecked U-boat — close to where the Robert E. Lee sank. The Navy's marine archaeologists determined that it was the U-166. But how did the U-boat die?

Returning to the crime scene

To gather evidence, Ballard and the crew of the expedition ship Nautilus sent remotely operated vehicles down to the site last summer. The resulting video footage is reminiscent of the Titanic operation: One of the camera-equipped robots got close enough to get eerie pictures of the U-boat's conning tower, radio antenna, periscope and gun emplacement.

"The crime scene is still there, undisturbed," Ballard said.

The strangest thing about the scene was that the front section of the U-boat was missing. After looking around with the ROVs, Ballard and his team identified that section, some distance away from the rest of U-166. Whatever happened, happened quickly and violently enough to break the sub apart.

An image from a remotely operated vehicle shows the conning tower from U-166, a Nazi U-boat that was sunk in the Gulf of Mexico in 1942. Ocean Exploration Trust - ROV

"Nazi Attack on America" shows how experts in underwater mapping and salvage were able to put the sub back together, virtually, and pinpoint the place where an explosion must have occurred. That place was in an area of the U-boat where spare torpedoes were stored.

The conclusion? Claudius and his crew were skilled enough — and lucky enough — to have one of the depth charges drop onto the U-boat's hull, right above where the torpedoes were kept. When the sub descended to evade the attack from the PC-566, the depth charge must have exploded, breaching the hull and setting off a catastrophic chain reaction with the torpedoes.

"This is really CSI," Richie Kohler, a diver and U-boat aficionado who was part of Ballard's team, says during the show.

Rescuing a reputation

Throughout the expedition, Ballard was passing along the team's findings to Navy Adm. Jonathan Greenert, an acquaintance who happens to be the chief of U.S. naval operations. "He got into it," Ballard said. Thanks to the new information, the Naval History and Heritage Command reviewed Claudius' case and decided that he and the PC-566's crew should be given credit for sinking the U-boat.

Claudius passed away in 1981, but his son Gordon received a Legion of Merit medal from Navy Secretary Ray Mabus during a ceremony in December. "It's never too late to set the record straight," Mabus said.

Among those who attended the ceremony were Ballard and the documentary film crew. "There wasn't a dry eye in the house," Ballard told NBC News.

Navy Secretary Ray Mabus shakes hands with Herbert Gordon Claudius Jr. after presenting him with a Legion of Merit medal posthumously honoring his father, Lt. Cmdr. Herbert Claudius, during a Pentagon ceremony on Dec. 16, 2014. Adm. Jonathan Greenert, chief of naval operations, applauds at right. Julianne F. Metzger / U.S. Navy

As we all know, Operation Drumbeat ultimately failed. The United States built up its aerial and naval resources during the year that followed Pearl Harbor, and code-breakers cracked the advanced Enigma cipher (known as "Shark") that was used by the German navy for U-boat radio transmissions. By the spring of 1943, Drumbeat had faded.

The operation's terrible legacy endures, however, on the bottom of the Gulf of Mexico — where U-166 and the ships it sank still lie. The site has been preserved as a war grave, and petroleum companies altered their plans to put a natural gas pipeline in the area.

Another infamous underwater locale is not that far away: the Macondo deep-sea drilling site, where 11 people died and millions of barrels of oil were spilled in 2010. That's where Ballard and the Nautilus are working on their next adventure.

"We're looking at the impact that the spill has had on deep-sea corals," Ballard said. This time, you don't have to wait for the TV documentary. You can watch streaming video from the ship via the Nautilus Live website.

Ballard said NautilusLive.org, like the Nova/National Geographic documentary, is aimed at getting the wider public involved in ocean adventures. The same goes for the educational expeditions organized by Ballard's Ocean Exploration Trust.

"It's all about using the excitement of exploration, and doing it live," he said.

"Nazi Attack on America," a Nova/National Geographic special, premieres on PBS on Wednesday night. Check local listings. The program is also available on DVD, and beginning Thursday it can be seen via the Nova and PBS website.