While baseball pro Moe Berg will never be remembered as one of the game’s greats — in an unremarkable career spanning from 1923 until 1939, the catcher was traded eight times — he does go down in history as the Major League’s all-star spy.

During World War II, Berg risked his life to investigate Germany’s progress in creating an atomic bomb. His key quarry was Werner Heisenberg, one of the world’s most brilliant physicists.

Berg’s story is dramatized in “The Catcher Was a Spy,” starring Paul Rudd as the catcher and opening in theaters Friday.

Born in Manhattan in 1902 to a pharmacist and a housewife, Berg played baseball at Barringer High School in Newark, NJ. He graduated from Princeton with a degree in classical and romance languages and became notorious for practicing Sanskrit from behind home plate. (Casey Stengel, the legendary Yankees and Mets manager, once said, “Moe Berg was the strangest man to ever play the game of baseball.”)

After first playing shortstop for the Brooklyn Robins in 1923, he filtered through various teams in the minor and major leagues, switched to catcher and managed to earn a law degree from Columbia University.

Berg actually kicked off his spy work in 1934 — on his own volition. In Tokyo on a goodwill baseball tour with Babe Ruth and Lou Gehrig, he donned a kimono and went to the roof of the tallest building. According to the book “The Catcher Was a Spy,” by Nicholas Dawidoff, Berg used a movie camera to film “shipyards, industrial complexes and military installations.”

“Crazy as it seems,” film director Ben Lewin said, “what Moe did was part of a plan.”

In the early 1940s, having retired from baseball, Berg showed the footage to “Wild” Bill Donovan, who headed up the Office of Strategic Services, a forerunner to the CIA. According to Lewin, “Moe often liked to think [his footage] was used to plan the Doolittle Raid” — America’s first aerial attack on Japan, in 1942.

The derring-do impressed Donovan, who was recruiting extraordinary civilians, including Julia Child and Hollywood director John Ford, for undercover jobs. After a crash course in lock-picking, killing and pyrotechnics, Berg got his first assignment, in 1944: Gather information about progress made by Germany on an atomic bomb.

He knew enough of physics to be conversant. He also had a secretive side that made him an ideal spy. According to screenwriter Robert Rodat, Berg played down being Jewish and successfully hid his supposed bisexuality — at a time when both drew derision.

“He was [both] a center of attention and a secretive man living in the shadows,” Rodat said.

Missions took Berg through Italy, England, Algeria and Yugoslavia; he once masqueraded as a Nazi officer to get into a munitions plant.

Meanwhile, back in America, concerns mounted that Heisenberg was behind a feared nuclear weapon. Arrangements were made for Berg to attend a Zurich lecture by the physicist. Pretending to be a student, Berg hid a gun in one pocket and a cyanide capsule in the other — the weapon for an assassination, the pill for suicide, if warranted.

‘He was [both] a center of attention and a secretive man living in the shadows’

At a dinner for Heisenberg one night later, Berg heard someone say that the war was all but lost for Germany. The physicist sourly responded, “Yes, but it would have been so good if we had won.”

The comment left Berg believing that Germany was far from completing its bomb. Still, he took pains to leave the event at the same time as Heisenberg, the two chatting as they walked the streets. Berg was perfectly positioned to assassinate the scientist. But, again, nothing that Heisenberg said suggested he was on the cusp of atomic discovery.

“Common wisdom was to kill Heisenberg,” said Lewin. “But Moe was a profound humanist.”

By 1954, Berg was out of what was by then the CIA. He led a low-key life until his death, in 1972, following a fall at his sister’s home. He was 70. But Berg had made no secret of his time spent as an undercover man, and even left the impression that he was at it until the end.

“Berg would be walking down streets in New York or Boston, where people he knew would see him and want to say hello,” said Rodat. “Moe would put a finger to his lips and say, ‘Shh.’ He let them assume he was a spy.”