FBI agents found him in the science fiction section of a small branch of the San Francisco public library, chatting online.

The man known as Dread Pirate Roberts — 29-year-old Ross William Ulbricht — was on his personal laptop Tuesday afternoon, authorities said, talking about the vast black market bazaar that is believed to have brokered more than $1 billion in transactions for illegal drugs and services.

When a half-dozen FBI agents burst into the library in a quiet, blue-collar neighborhood, they abruptly ended Ulbricht's conversation with a cooperating witness, pinned the Austin, Texas, native to a floor-to-ceiling window and then took him off to jail, law enforcement and library spokeswomen said.

Ulbricht was later charged in criminal complaints in federal courts in New York and Maryland. He's accused of making millions of dollars operating the secret Silk Road website and of a failed murder-for-hire scheme, all while living anonymously with two roommates whom he paid $1,000 to rent a room in a modest neighborhood.

Federal authorities shut down the website.

Ulbricht has not entered pleas to any of his charges. His federal public defender in San Francisco declined to comment Wednesday. Ulbricht is due back in San Francisco federal court Friday morning to discuss bail and his transfer to New York, where the bulk of the charges have been filed.

He is charged in New York with being the mastermind of Silk Road, where users could browse anonymously through nearly 13,000 listings under categories like "Cannabis," `'Psychedelics" and "Stimulants."

Charged with ordering murder

Ulbricht also is charged in Maryland with ordering first the torture, and then the murder, of an employee from an undercover agent. He feared the employee would expose his alias as Dread Pirate Roberts, a fictional character. Court records say he wired the agent $80,000 after he was shown staged photos of the employee's faked torture.

His arrest culminated a two-year-investigation that painstakingly followed a small trail of computer crumbs Ulbricht carelessly left for the FBI to find, according to court documents.

Ulbricht first came to the attention of federal agents in 2011 when they figured out he was "altoid," someone who they say was marketing Silk Road on other drug-related websites the FBI was watching. In October 2011, "altoid" posted an advertisement for a computer expert with experience in Bitcoin, an electronic currency, and gave an email address.

From there, investigators began to monitor Ulbricht's online behavior closely, according to the court records. Investigators said Ulbricht was living within 500 feet of a San Francisco Internet cafe on June 3, 2013, when someone "logged into a server used to administer the Silk Road website."

Court documents show investigators slowly connected Ulbricht to Silk Road by monitoring his email and picking up on some slipups, including using his real name to ask a programmers' website a highly technical question about connecting to secret sites like Silk Road.

Final mistake was fake ID from Canadian vendor

His final mistake, according to the court papers, was ordering fake identification documents from a Silk Road vendor from Canada. One of the nine documents was a California driver's license with Ulbricht's photograph, birthdate but a different name. The package was intercepted at the border during a routine U.S. Customs search.

On July 26, Homeland Security investigators visited Ulbricht at his San Francisco residence. He "generally refused to answer questions," the agents said.

The investigators left that day without arresting Ulbricht, who holds a bachelor's of science degree in physics from the University of Texas at Dallas and a master's degree from Penn State University.

They returned Tuesday and arrested him at the library. He faces the prospect of life in prison if convicted of all the charges.

The Silk Road website protected users with an encryption technique called "onion routing," which is designed to make it "practically impossible to physically locate the computers hosting or accessing websites on the network," court papers said. One listing for heroin promised buyers "all rock, no powder, vacuum sealed and stealth shipping," and had a community forum below where one person commented, "Quality is superb."

The defendant announced in a website forum in 2012 that to avoid confusion he needed to change his Silk Road username, according to court papers released Wednesday. He wrote, "drum roll please ... my new name is: Dread Pirate Roberts," an apparent reference to a swashbuckling character in "The Princess Bride," the 1987 comedy film based on a novel of the same name.

As of July, there were nearly 1 million registered users of the site from the United States, Germany, Russia, Australia and elsewhere around the globe, the court papers said. The site generated an estimated $1.2 billion since it started in 2011 and collected $80 million by charging 8 to 15 percent commission on each sale, they said.