Daniel Beckwitt, a successful stock trader and computer whiz, was fixated on underground nuclear bomb shelters.

Askia Khafra, living five miles away in the Maryland suburbs, aspired to be an entrepreneurial millionaire.

The pair met two years ago on social media. And Beckwitt, 27, agreed to invest thousands of dollars in the ­21-year-old Khafra’s start-up venture called “Equity Shark,” which was to be a web-based investors’ platform.

“Mr. Beckwitt represented himself as an angel investor,” Khafra’s father, Dia Khafra, recalled this week. “I wish my son had not been so naive as to trust this gentleman.”

Their relationship now stands at the heart of a homicide case unfolding in Montgomery County. On Thursday, Beckwitt was formally indicted by a county grand jury on charges of involuntary manslaughter and second-degree murder. It was the Equity Shark investment, prosecutors say, that helped Beckwitt entice Khafra to work on a sprawling bunker complex Beckwitt was building beneath his home in a quiet Bethesda neighborhood.

Beckwitt went to extreme lengths to keep the project secret, prosecutors say: He would pick up Khafra at Khafra’s home, drive him to Virginia, have him don “blackout glasses,” drive him back to Bethesda, and then guide him into his home along a string. It was only when Khafra got to the basement — near the ground entrance to the tunnels — that he was allowed to remove the glasses that prevented him from seeing.

His work involved using electrical excavation tools to burrow the tunnels, where he sometimes ate and slept.

On the afternoon of Sept. 10, a fire broke out in the basement. Khafra, who investigators say was nearby at the time, was burned to death.

Prosecutors allege Beckwitt acted with “extreme disregard” for Khafra’s well-being because Beckwitt knew about the fire danger created by the tunneling project and knew there was so much clutter and hoarding in the house that it would be difficult to flee a blaze. His actions, they say, amounted to “depraved heart” murder under Maryland law, punishable by up to 30 years in prison.

“The defendant did not care about Askia Khafra,” Assistant State’s Attorney Douglas Wink said in court Thursday. He asked Circuit Judge Sharon Burrell to hold Beckwitt in jail under no-bond status, meaning that he would have been there until his trial or until the case was concluded.

Burrell assigned a $100,000 bond in the case, an amount that — given his financial means — Beckwitt probably will be able to post. Burrell sided with Beckwitt’s attorney, Robert Bonsib, who argued that his client was not a danger to the community.

“It was a tragic accident,” Bonsib said.

His client, who participated in the hearing via a video link from the Montgomery County jail after his recent arrest, said little, as is customary for such proceedings. He subtly nodded or shook his head, depending on the points being made.

“I will grant you this,” Bonsib told the judge, “Mr. Beckwitt is — and I say this respectfully to my client — an unusual individual.”

As Beckwitt nodded, Bonsib described how Beckwitt had spoken at computer hacker conferences. Moments earlier, Bonsib had described how Beckwitt had amassed millions as a day-trader of stocks, and explained why there were tunnels beneath his home.

“It was his project to create a secure bunker because of his concern about international tensions, North Korea, intercontinental ballistic missiles,” Bonsib said, comparing Beckwitt’s tunneling project with nuclear shelters built during the Cold War.

Beckwitt grew up in Bethesda, according to Bonsib, and went to college in Illinois.

While there, Bonsib said, his client collected the only criminal “blip” on his record — a conviction the attorney described that arose from a “computer-related crime” and which the prosecutor said Thursday was “computer hacking.” Beckwitt was placed on probation. He returned to Bethesda and at some point launched the tunneling project.

The network started at a 20-foot drop from a hole in his basement and branched into tunnels totaling about 200 feet, according to prosecutors and police. Khafra began working in the basement last year. He would generally be gone from his Silver Spring home for days at a time. The exact working and financial agreements of his labor remain in dispute.

Bonsib called it a regular work agreement, one that Khafra liked enough to return and thought was safe enough that he kept working.

Khafra posted photos from the dig on his Twitter and Facebook pages, which Bonsib submitted as evidence in court Thursday. “Askia was a willing and experienced participant in this venture,” Bonsib said.

But Wink, the prosecutor, described the seemingly friendly arrangement as scheming on Beckwitt’s part bolstered by the show of faith made by investing in Khafra’s start-up operation.

“The defendant enticed him into friendship and into his home by investing a substantial amount of cash — thousands and thousands of dollars — in Askia Khafra’s technology start-up,” Wink said. “The defendant promised more money if Askia Khafra would come into his home and dig in tunnels underneath his home.”

Wink described the large electricity needs of the project, which included the digging tools as well as lights, an air circulation system and heating. The equipment was fed by what Wink called a dangerous, “haphazard daisy chain” of power cords. And on the day of the fire, hours before it broke out, Beckwitt was aware of the smell of smoke in the basement, according to Wink, but reacted only by adjusting the circuit breakers.

“The defendant knew it as an imminent fire danger,” Wink said, as Beckwitt shook his head in disagreement.

Khafra grew up in Silver Spring. He learned to play the trombone and guitar, competed in wrestling and lacrosse, and was a member of the Navy Junior ROTC, according to his father.He graduated from Northwood High School and took classes at Montgomery College.

But Khafra was more interested in starting his own businesses and often told his father that some of the country’s most successful entrepreneurs dropped out of college.

“He intended to be a millionaire,” Dia Khafra said.

His son spoke about the work, and indicated that the tunnel complex included a locked chamber that he was not allowed to enter. “I am glad that Montgomery County police uncovered enough evidence,” he said,” to justify my contention that Mr. Beckwitt murdered my son.”

At their home in Silver Spring, Dia Khafra and wife mourn their son every day. His ashes remain in an urn in an unopened box in the living room. “Neither of us have the courage to open it,” he said.

His son, he said, was warm and kind. “I miss his hugs,” Dia Khafra said. “He was not afraid to say, ‘I love you.’ ”

Their son’s bedroom is largely unchanged from when he was alive — his books, dumbbells, a video game console and other items. Dia Khafra said he has gone into it only a few times since his son’s death.

“It’s too painful,” he said. “His smiling face is no longer there.”