(CNN) -- Three hostages were rescued from the headquarters of the Discovery Channel in Silver Spring, Maryland, Wednesday afternoon after police shot and killed the man who was holding them, officials said.
The hostages were unharmed, said Police Chief J. Thomas Manger of the Montgomery County Police Department.
The suspect, identified by a law enforcement official as James Lee, earlier was in communication with authorities.
A number of devices in backpacks that Lee held have to be rendered safe, Manger added.
Manger said hostage negotiators negotiated for almost four hours by phone with Lee while police officers watched and listened to Lee on the building's surveillance system.
"At times during the negotiations, he was calm, but I wouldn't call him lucid. The conversation was indicative to me he was dealing with some mental issues," he said.
iReport: Are you there? Send us news, videos
Manger said the three hostages were lying on the ground, but were not otherwise constrained. He said Lee mainly dealt with the hostage negotiators and did not communicate with the hostages.
"He stayed on point with his issues with Discovery," Manger said.
At one point, one of the hostages moved, drawing Lee's attention, Manger said. Lee pulled his gun and aimed it at the hostages, and it was at that point that a sniper inside the building took the shot that killed Lee, he said.
Another police official, Capt. Paul Starks, said the decision to shoot the gunman was made after authorities heard a gunshot or explosion go off in the area. As the police moved in, the hostages were running out, he said.
Police believe, at least initially, that Lee was acting alone, Starks said.
During the negotiations, Lee exhibited a "range of emotions," Manger said. At times he was agitated and at times he was calm, but he never strayed far from his grievance against Discovery, he said.
According to a police spokesman, the suspect entered the building's main entrance "wearing what appeared to be metallic canister devices on his front and back. He also pulled a handgun out and was waving a handgun."
According to Manger, Lee may have fired a shot when he entered the building. The three hostages held inside were a security guard and two other males, he said.
iReports: On the scene | More photos
Discovery Channel spokesman David Leavy said company officials were familiar with Lee, who had protested at the network in 2008, but the company "did not take his threats or demands seriously."
During the standoff, fewer than 10 Discovery Channel employees remained in the building "for a while, to assist law enforcement on navigating the building and the infrastructure and then we were all evacuated about an hour, 90 minutes into it," Leavy said.
He added, "Our hope and expectation is that tomorrow morning we will be open for business and we will be making great TV again."
Montgomery County Fire and Rescue Battalion Chief Kevin Frazier said that before employees return to the building, authorities would search it for possible bombs.
Lee was linked to a manifesto that was posted on the internet, a source close to the investigation told CNN.
The angry manifesto repeatedly refers to humans as "filth" and demands that the Discovery Channel "stop encouraging the birth of any more parasitic human infants."
"Civilization must be exposed for the filth it is," the 1,149-word statement says.
Starks said during the situation that Lee was making some demands, and that the suspect had "concerns" with Discovery Communications.
A person at One Discovery Place, the channel's headquarters, called police about 1 p.m. to report a man with a gun and possible explosives, said Angela Cruz, a police spokeswoman.
The area was evacuated, she said. A day care center inside One Discovery Place was emptied, and the children were moved temporarily to a nearby McDonald's restaurant, authorities said. Witnesses said some of the children were in cribs on wheels, and that people pushed the cribs out of the building to safety.
iReport: Photos of cribs being moved
Most of the 1,900 employees of the building were evacuated, but "a few" apparently remained on the upper floors, Manger said during the standoff.
Lori Rorke told CNN that she was on the second floor when she and her co-workers heard about the man.
"When we first heard the news, we heard that the gunman was mobile and we were told to go into locked offices," she said. "We were really panicking, then trying to keep it under control."
But, she said, fellow workers carrying BlackBerry devices seemed to know what to do, and led her out of the building via a route that avoided the lobby.
Street view of Discovery Channel headquarters
Lee was linked to the online screed, which said in part, "Humans are the most destructive, filthy, pollutive creatures around and are wrecking what's left of the planet with their false morals and breeding culture."
The writer blasted immigration, farming, weapons of mass destruction, automotive pollution, "and the whole blasted human economy."
He demanded that the Discovery Channel broadcast daily prime-time shows devoted to "solutions to save the planet," perhaps in a game-show format, insisting, "Make it interesting so people watch and apply solutions!!!!"
Many of the writer's comments were directed at "the media," saying, "You can reach enough people. It's your responsibility because you reach so many minds!!!"
"The world needs TV shows that DEVELOP solutions to the problems that humans are causing, not stupify the people into destroying the world. Not encouraging them to breed more environmentally harmful humans," the manifesto says.
"These are the demands and sayings of Lee," the manifesto concludes.
Aaron Morrissey, the editor-in-chief of the web publication DCist, said he came across James Lee's anti-Discovery Channel manifesto in 2008, when Lee was planning to hold a protest against the channel.
Discovery programming and the hostage incident
The 2008 protest, he said, "was not that well attended."
A month or so later, Lee was arrested near the building on littering and disorderly conduct charges, Morrissey said. The littering charge stemmed from Lee's throwing money into the air, he said.
According to court records, a man with the same name and age as Lee was found guilty in 2008 of disorderly conduct.
James Lee was acquitted of littering in the same case, according to Montgomery County, Maryland, Circuit Court records, said Eric Nee, a senior assistant state's attorney.
Lee's two-year supervised probation ended August 18, records show.
Because of the 2008 incident, a judge had warned Lee that year not to come within 500 feet of Discovery Communications, according to Maryland's Gazette newspaper.
More coverage from CNN affiliate WJLA
Lee spent nearly two weeks in jail following his arrest and several days being evaluated by state psychiatrists, he said. ''I told them my idea of saving the planet," Lee was quoted in the Gazette. ''They couldn't find anything wrong with me."
Lee said he began his crusade to save the planet after being laid off from his job in San Diego and reading ''Ishmael," a novel by Daniel Quinn about a gorilla that tells a man what it is like to live in captivity in a world where humans exploit natural resources.
More coverage from CNN affiliate WUSA
Lee said he then felt an ''awakening," watched former Vice President Al Gore's documentary ''An Inconvenient Truth," and decided he had been doing too little to protect the environment.
CNN's Mike Ahlers, Charley Keyes, Carol Cratty and Brianna Keiler contributed to this report.