SAN FRANCISCO—In certain wealthy tech circles it is known as “The Lifestyle,” an underground party scene featuring recreational drug use and casual sex.

A successful tech executive named Bob Lee liked to hang out with that crowd, according to people who also participated. So, too, did Khazar Momeni, the wife of a prominent plastic surgeon, these people said.

On the afternoon of April 3, a Monday, the partying took a dark turn. According to San Francisco prosecutors, Ms. Momeni’s older brother confronted Mr. Lee about her. Was she taking drugs or doing anything inappropriate, he wanted to know. Hours later the brother, Nima Momeni, stabbed Mr. Lee with a kitchen knife and left him to bleed out in the street, prosecutors alleged. Mr. Momeni, who was arrested on suspicion of murder, is being held without bail. He plans to plead not guilty, his attorney said. 

Mr. Lee’s death has transfixed San Francisco. At first viewed by critics including Elon Musk as a symbol of the city’s increasing street violence, the episode instead laid bare risk-taking behavior in the upper reaches of Bay Area society, fueled by cocaine and designer drugs. 

Libertine though it might seem, the party scene is governed by an unwritten code of conduct, said Devon Meyers, a friend of Mr. Lee who saw him a few days before he died. “There is still an understanding of consent and boundaries,” he said, adding that, if someone gets drunk and handsy, “they get excommunicated very quickly.” 

This account is based on interviews with friends, co-workers and acquaintances of Mr. Lee and the Momeni family, and records released by city agencies, including the District Attorney’s office.

Mr. Momeni, the accused killer, was known to use drugs himself but wasn’t seen as part of the elite crowd. He ran an IT consulting firm out of a live-work loft in Emeryville, a small city across the bay from San Francisco. Public records paint a picture of a struggling business. Acquaintances describe him as aloof and introverted, unlike his wealthy and glamorous sister, and prone to brood on the sidelines at parties.

While prosecutors have said Mr. Lee and Ms. Momeni had met previously, his shared history with the Momeni family runs deeper than investigators have revealed.

Friends of Mr. Lee said he told them that he was casually sleeping with Ms. Momeni, 37. Before that, about three years ago, Mr. Lee, 43, was together with a woman that Mr. Momeni, 38, also had dated, according to people familiar with the relationships. 

Bob Lee in San José del Cabo, Mexico.

Photo: Gift Kerati

Mr. Momeni is expected to appear at an arraignment and detention hearing later this month. Prosecutors haven’t offered a motive for his alleged crime. His attorney, Paula Canny, said, “My team and I continue to work hard to investigate all the many aspects of this case and the goings-on of the weeks preceding the incident.”

 Mary McNamara and Ed Swanson, attorneys for Ms. Momeni, said in a written statement, “There are many rumors circulating around this case, many of them untrue,” adding, “Ms. Momeni loves and supports her brother. What happened here is a tragedy, and Ms. Momeni is deeply saddened at the suffering of the Lee family as they deal with their terrible loss.”

Some of Mr. Lee’s friends say they had become worried in recent months that he was getting in over his head. Dana Wagner, the former general counsel of payments company Square, now known as Block, said Mr. Lee was comfortable with a lot of different crowds and that he was creative and adventurous, loyal to his friends, and “saw the best in everyone.”

“He was also hanging out with people who weren’t great people, and that was part of what happened in the end,” said Mr. Wagner, who says he didn’t know the Momenis. “There are a lot of swingers, cheaters and liars in that crowd,” he said.

Mr. Lee remained close to his wife, Krista Lee, even though they were separated. He recently moved to Miami with his father, a widower, but regularly returned to San Francisco to visit his two teenage children, Dagny and Scout, named after characters in “Atlas Shrugged” and “To Kill A Mockingbird.” The family had planned a trip together to Japan in August. 

“He was kind and generous—he saw the good in everybody,” said Ms. Lee in an interview, adding that they texted every day. She disputed that Mr. Lee was a “party boy” and said she has never heard the term “The Lifestyle.” 

“He was a dedicated father. He was more mature than that,” she said. At the most, she said she suspected he was microdosing ketamine as a treatment for depression.

Flowers were left at the scene of the stabbing death of technology executive Bob Lee.

Photo: Jeff Chiu/Associated Press

On May 5, Ms. Lee hosted a private memorial for his many friends at San Francisco’s iconic Ferry Building, a gathering that began with shared remembrances and ended with an all-night dance party featuring Rob Garza of the Thievery Corporation, one of Mr. Lee’s favorite DJs. 

Participants wrote letters to Mr. Lee and left them in a box, which the family plans to set on fire at the annual Burning Man music festival in the Nevada desert this summer—one of Mr. Lee’s favorite events.

‘The dumbest smart person I knew’

Mr. Lee, who was raised in the Midwest, was a brilliant computer programmer. One of his first feats, while at Southeast Missouri State University, was to create code that defeated an insidious computer bug, an effort later dubbed “Code Red Vigilante.”

He worked at Google and helped write the code for the Android operating system. Later, he was named chief technology officer of Square, where he helped design the company’s popular Cash App, a Venmo competitor. He left the company in 2014. 

He was an investor in SpaceX, the rocket company run by Elon Musk, and Figma, the collaboration-software business acquired by Adobe for $20 billion last year. At the time of his death, he was working as chief product officer for a crypto startup, MobileCoin. Friends described Mr. Lee as a multimillionaire, but his net worth couldn’t be learned.

Mr. Lee was physically fit and sported a wide grin. Friends say he was a happy person, selfless with his time and knowledge.

Any time Kyle Zink, a former co-worker at Square, asked him a question, “Bob would instantly run up to the white board, take out one of those dry erase markers and sketch the most complex but also easy-to-understand diagram you could possibly imagine,” he said.

Mr. Lee was generous with friends. He frequently offered to pay for meals and Ubers and fund charities or business ventures. He bought a Tesla for a woman he was seeing, Mr. Wagner said. One of his former girlfriends said Mr. Lee once treated friends to a trip to Tulum, Mexico, on a whim, covering all the costs. When the girlfriend’s iPhone was stolen during the trip, Mr. Lee hired someone to secure a new one for her, she added. 

He kept a list of 20 close friends on his phone, to remind him to check in on them regularly, just to see how they were doing, according to a woman he traveled with extensively. In interviews for this article, multiple people described themselves as “Bob’s best friend.” 

Mr. Lee was serious about his work in the tech industry, but he was also dedicated to having fun. He took ecstasy, ketamine, cocaine and attended all-night raves all around the world, including at Club Audio in San Francisco, according to his friends. 

Once, a club offered to admit people for only $5 instead of $20 if they went in with no pants. Mr. Lee obliged, said his friend Harper Reed, the chief executive of General Galactic Corporation, a financial technology startup, who also went pantless.

During the pandemic, with the San Francisco party scene largely shut down, Mr. Lee spent months traveling around Los Angeles and Mexico, said Gift Kerati, a friend of his from Thailand who said she spent much of that time with him. 

Ms. Kerati, who met Mr. Lee at a private party in Acapulco, said that Mr. Lee had several girlfriends during that time and other women he was sleeping with, but that he was always respectful toward them.

“He is literally one of the best human beings I’ve ever met,” said Ms. Kerati. 

She said Mr. Lee attended parties and used drugs because he liked to share experiences with a lot of different people, from all walks of life. 

“He loved to exchange ideas,” Ms. Kerati said.

Mr. Meyers, the friend who saw Mr. Lee a few days before he died, said people like him are often attracted to the underground party scene because it provides them with different experiences and connections.

“They’re highly functioning, very intelligent people, incredibly talented, and there’s not much in our world for them to do,” said Mr. Meyers, who builds art installations.

To some, “The Lifestyle” is narrowly focused to describe people who might engage in various sexual activities with different partners. In San Francisco, it is used more loosely to describe an underground party scene that has evolved since the city’s early days as an incubator of the countercultural movement. 

It started with the hippies, who were not sober people, trying to expand their brains and the tech people came in and gentrified it like they did everything else,” said Mr. Reed of General Galactic.

In recent months Mr. Wagner, Mr. Lee’s friend and former colleague from Square, noticed that the people who he was hanging around with seemed less playful, and more rough around the edges.

A document of ‘Notice of Motion and Motion to Detain Without Bail’ against Nima Momeni in the stabbing death of Bob Lee.

Photo: Photo illustration: WSJ; Photos: Superior Court of the State of California, istock (2)

Mr. Wagner said Mr. Lee’s generous nature meant he could sometimes be naive, trusting people who didn’t have his best interests at heart. Sometimes he didn’t notice; other times Mr. Lee didn’t seem to care. On a trip to Cuba, a street vendor charged $25 instead of 25 cents for an ice cream. Mr. Lee agreed to try to get his money back only after strong urging from Mr. Wagner.

“Bob was the dumbest smart person I knew,” said Mr. Wagner.

The Momeni family

Ms. Momeni and her older brother Nima were born in Iran to a family that is Zoroastrian, an ancient religion whose members were persecuted in that country, according to people familiar with the family. They moved to the U.S. with their mother, a dental assistant, and settled in the Bay Area. The siblings were very close, with Mr. Momeni frequently following his sister, who goes by “Tina,” around clubs or parties.

Mr. Momeni had scrapes with the law. In August 2022, Mr. Momeni was cited by local police for domestic battery, but the district attorney declined to file charges. His attorney, Ms. Canny, said the allegation wasn’t true.

In 2016, Mr. Momeni’s IT consulting firm, Expand IT, was suspended by the state tax board. In 2017, the IRS said he owed $18,433 in taxes from previous years.

Ms. Canny described her client as a generous man who once paid for a relative’s operation in Iran. “He very much wants people to like him,” she said. 

Several years earlier, the paths of Messrs. Momeni and Lee crossed over a woman, according to Keith Kraft, a friend of both the woman and Mr. Lee. 

Mr. Kraft said he recalled hanging out once with the woman and Mr. Momeni, and Mr. Momeni kept shooting him threatening glances, as if he might steal the friend away from him. Finally, Mr. Kraft said he told him, “Look, bro, I’m gay, I’m not a threat to you.”

“Obviously he had some major insecurities going on,” he said.

After the friend broke up with Mr. Momeni, she later began seeing Mr. Lee, Mr. Kraft said.

Khazar Momeni and her husband, Dr. Dino Elyassnia, attend a court appearance by her brother Nima Momeni in San Francisco on April 14.

Photo: Justin Katigbak

At another point, following a breakup with a longer-term girlfriend, Mr. Lee told friends that he was casually sleeping with Ms. Momeni, according to people familiar with their relationship.  

Ms. Momeni “was married, but the relationship had possibly been in jeopardy,” prosecutors have alleged in court documents.

Ms. Momeni’s husband, Dino Elyassnia, is a prominent San Francisco plastic surgeon. His Instagram page, with more than 30,000 followers, shows the results of nose jobs and face-lifts. “Happy International Women’s Day to my wife and all the amazing women I work with every day in our office,” wrote Mr. Elyassnia in a March post, showcasing a photo of Ms. Momeni in a tank top.

“Bob Lee’s death was an awful, unintended tragedy,” said Douglas Horngrad, an attorney for Mr. Elyassnia. “This is a very sad story for everyone.”

Prosecutors allege that on the afternoon of April 3, Mr. Lee met up with Khazar Momeni at a house party in San Francisco.

The condo belonged to Jeremy Boivin, who has known Mr. Lee for some time, according to his friends. 

In 2020, Mr. Boivin was criminally charged in San Francisco with drugging and sexually assaulting an individual, according to court records. He was also charged with possessing for sale illegal party drugs including ketamine and MDMA. He pleaded guilty to possession of illegal drugs, according to court records. He was put on probation and ordered to undergo drug treatment, the records state. 

Valery Nechay, an attorney for Mr. Boivin said that the sexual-assault allegations weren’t true and were dropped.

In a written statement, Mr. Boivin called Mr. Lee “a cherished personal friend who not only offered unwavering support but also served as a wise confidant in times of need.”  

After the gathering at Mr. Boivin’s condo, say prosecutors, a witness overheard a conversation in which Mr. Momeni confronted Mr. Lee, asking whether Ms. Momeni was doing drugs or “anything inappropriate.” Mr. Lee assured Mr. Momeni that nothing inappropriate had happened, prosecutors said, citing the witness.

Results of Bob Lee’s toxicology report from the office of the chief medical examiner in San Francisco.

Photo: Photo illustration: WSJ; Photos: San Francisco Chief Medical Examiner, istock (2)

Later that night, Messrs. Momeni and Lee met at Ms. Momeni’s apartment in Millennium Tower, a luxury condo building with commanding views of the San Francisco Bay. 

Surveillance footage from the Millennium Tower shows Mr. Momeni pull up in a white BMW, and then later, around 2 a.m., Messrs. Lee and Momeni leave the building and climb into Mr. Momeni’s car together.

Prosecutors allege that Mr. Momeni drove Mr. Lee to a dark and secluded area several streets over, in San Francisco’s Rincon Hill neighborhood. The area is punctuated with upscale condo buildings. The lights of the Bay Bridge that connects the city to Oakland and Berkeley sparkle behind office towers.

They allege that Mr. Momeni used a silver kitchen knife with a four-inch black blade to repeatedly stab Mr. Lee. Mr. Momeni drove quickly away from the scene, according to court documents that cite surveillance video.

Mr. Lee, bleeding profusely, called 911 for help before collapsing on the sidewalk. He was rushed to a hospital, where he later died.

Mr. Lee’s autopsy report revealed a number of drugs in his system, including cocaine and ketamine, according to the San Francisco Office of the Chief Medical Examiner. It was “the Walgreens of recreational drugs,” Mr. Momeni’s attorney, Ms. Canny, told reporters in early May. She later apologized for the “insensitive” comments.

Investigators later recovered a text from Ms. Momeni to Mr. Lee’s phone, sent after he and her brother left her home: “Just wanted to make sure your (sic) doing ok Cause I know nima came wayyyyyy down hard on you And thank you for being such a classy man handling it with class Love you Selfish pricks.”

Nima Momeni, the man charged in the fatal stabbing of Bob Lee, makes his way into the courtroom.

Photo: Gabrielle Lurie/Pool San Francisco Chronicle/Associated Press

Inside the Millennium Tower, a flier advertised a “Murder Mystery Cocktail Party: Midnight at the Masquerade,” planned for later that month. After Mr. Lee’s passing, the event was postponed to June and the theme was changed to “Diamond Heist.”

Write to Kirsten Grind at kirsten.grind@wsj.com, Katherine Bindley at katie.bindley@wsj.com and Zusha Elinson at zusha.elinson@wsj.com