Hammett was born on a farm in Saint Mary's County, Maryland. His parents were Richard Thomas Hammett and Anne Bond Dashiell; his mother belonged to an old Maryland family, whose name in French was De Chiel. He had an older sister, Aronia, and a younger brother, Richard Jr. Known as Sam, Hammett was baptized a Catholic, and grew up in Philadelphia and Baltimore.
He left school when he was 13 years old and held several jobs before working for the Pinkerton National Detective Agency. He served as an operative for Pinkerton from 1915 to February 1922, with time off to serve in World War I. While at Pinkerton he was sent to Butte, MT during the Union Strikes. The agency's role in union strike-breaking eventually left him disillusioned.
Hammett enlisted in the Army in 1918 and served in the Motor Ambulance Corps. He was afflicted during that time with the Spanish flu and later contracted tuberculosis. He spent most of his time in the Army as a patient at Cushman Hospital in Tacoma, Washington, where he met a nurse, Josephine Dolan, whom he married on July 7, 1921 in San Francisco.
Hammett and Dolan had two daughters, Mary Jane (born 1921) and Josephine (born 1926). Shortly after the birth of their second child, Health Services nurses informed Dolan that due to Hammett's TB, she and the children should not live with him full-time. Dolan rented a home in San Francisco, California, where Hammett would visit on weekends. The marriage soon fell apart, but he continued to financially support his wife and daughters with the income he made from his writing.
Hammett was first published in 1922 in the magazine The Smart Set. Known for the authenticity and realism of his writing, he drew on his experiences as a Pinkerton operative. Hammett wrote most of his detective fiction while he was living in San Francisco in the 1920s; streets and other locations in San Francisco are frequently mentioned in his stories. He said that "All my characters were based on people I've known personally, or known about." His novels were one of the first to use dialogue that sounded authentic to the era. "I distrust a man that says when. If he's got to be careful not to drink too much, it's because he's not to be trusted when he does". (The Maltese Falcon, 1929)
Raymond Chandler, often considered Hammett's successor, summarized his accomplishments in The Simple Art of Murder:
Hammett was the ace performer... He is said to have lacked heart; yet the story he himself thought the most of, The Glass Key, is the record of a man's devotion to a friend. He was spare, frugal, hard-boiled, but he did over and over again what only the best writers can ever do at all. He wrote scenes that seemed never to have been written before.
In 1929 and 1930, he was romantically involved with Nell Martin, a writer of short stories and several novels. He dedicated The Glass Key to her, and in turn, she dedicated her novel Lovers Should Marry to him.
In 1931, Hammett embarked on a 30-year affair with the playwright Lillian Hellman. Though he sporadically continued to work on material, he wrote his final novel in 1934, more than 25 years before his death. It is not certain why he moved away from fiction; Hellman speculated in a posthumous collection of Hammett's novels that "I think, but I only think, I know a few of the reasons: he wanted to do new kind of work, he was sick for many of those years and getting sicker." In the 1940s, he and Hellman lived at her farm, Hardscrabble Farm, in Pleasantville, New York.
Hammett devoted much of his life to left-wing activism. He was a strong anti-fascist throughout the 1930s and in 1937 joined the Communist Party. He suspended his anti-fascist activities when, as a member (and in 1941 president) of the League of American Writers, he served on its Keep America Out of War Committee in January 1940 during the period of the Molotov–Ribbentrop Pact.
Especially in Red Harvest, book reviewers have seen a Marxist critique of the social system. Hammett's biographer, Richard Layman, calls such interpretations "imaginative" but he nonetheless objects to them, since, among other reasons, there are no "masses of politically dispossessed people" in this novel. Herbert Ruhm has found out that Hammett's contemporary left wing media already viewed him with skepticism, "perhaps because his work suggests no solution: no mass-action ... no individual salvation ... no Emersonian reconciliation and transcendence". In a letter of November 25, 1937, to his daughter Mary, Hammett referred to himself and others as "we reds". He confirmed that "in a democracy all men are supposed to have an equal say in their government" but added that "their equality need not go beyond that." He also found that "under socialism there is not necessarily [...] any leveling of incomes.".
In early 1942, following the attack on Pearl Harbor, Hammett again enlisted in the United States Army. He was a disabled veteran of World War I, a victim of tuberculosis, and a Communist, but he pulled strings in order to be admitted. However, biographer Diane Johnson suggests that confusion over Hammett's forenames was the reason he was able to re-enlist. He served as a sergeant in the Aleutian Islands, where he edited an Army newspaper entitled The Adakian. In 1943, while still a member of the military, he co-authored The Battle of the Aleutians with Cpl. Robert Colodny, under the direction of an infantry intelligence officer, Major Henry W. Hall. While in the Aleutians he developed emphysema.
After the war, Hammett returned to political activism, "but he played that role with less fervour than before." He was elected President of the Civil Rights Congress (CRC) on June 5, 1946, at a meeting held at the Hotel Diplomat in New York City, and "devoted the largest portion of his working time to CRC activities".
In 1946, a bail fund was created by the CRC "to be used at the discretion of three trustees to gain the release of defendants arrested for political reasons." Those three trustees were Hammett, who was chairman, Robert W. Dunn, and Frederick Vanderbilt Field, "millionaire Communist supporter." On April 3, 1947, the CRC was identified as a Communist front group on the Attorney General's List of Subversive Organizations, as directed by U.S. President Harry S. Truman's Executive Order 9835.
The CRC's bail fund gained national attention on November 4, 1949, when bail in the amount of "$260,000 in negotiable government bonds" was posted "to free eleven men appealing their convictions under the Smith Act for criminal conspiracy to teach and advocate the overthrow of the United States government by force and violence." On July 2, 1951, their appeals exhausted, four of the convicted men fled rather than surrender themselves to federal agents and begin serving their sentences. The United States District Court for the Southern District of New York issued subpoenas to the trustees of the CRC bail fund in an attempt to learn the whereabouts of the fugitives.
Hammett testified on July 9, 1951, in front of United States District Court Judge Sylvester Ryan, facing questioning by Irving Saypol, the United States Attorney for the Southern District of New York, described by Time as "the nation's number one legal hunter of top Communists". During the hearing, Hammett refused to provide the information the government wanted, specifically the list of contributors to the bail fund, "people who might be sympathetic enough to harbor the fugitives." Instead, on every question regarding the CRC or the bail fund, Hammett declined to answer, citing the Fifth Amendment, refusing to even identify his signature or initials on CRC documents the government had subpoenaed. As soon as his testimony concluded, Hammett was found guilty of contempt of court.
Hammett served time in a West Virginia federal penitentiary where, according to Lillian Hellman, he was assigned to clean toilets. Hellman noted in her eulogy of Hammett that he submitted to prison rather than reveal the names of the contributors to the fund because "he had come to the conclusion that a man should keep his word."
During the 1950s, Hammett was investigated by Congress. He testified on March 26, 1953, before the House Un-American Activities Committee about his own activities but refused to cooperate with the committee. No official action was taken, but his stand led to his being blacklisted, along with others who were blacklisted as a result of McCarthyism.
Hammett became an alcoholic before working in advertising and alcoholism continued to trouble him until 1948, when he quit after his doctor's orders. However, years of heavy drinking and smoking worsened the tuberculosis he contracted in World War I, and then according to Hellman "jail had made a thin man thinner, a sick man sicker ... I knew he would now always be sick."
Hellman wrote that during the 1950s Hammett became "a hermit", his decline evident in the clutter of his rented "ugly little country cottage", where "signs of sickness were all around: now the phonograph was unplayed, the typewriter untouched, the beloved foolish gadgets unopened in their packages." He may have meant to start a new literary life with the novel Tulip but left it unfinished, perhaps because he was "just too ill to care, too worn out to listen to plans or read contracts. The fact of breathing, just breathing, took up all the days and nights." Hammett could no longer live alone, and they both knew it, so he spent the last four years of his life with Hellman. "Not all of that time was easy, and some of it very bad", she wrote, but, "guessing death was not too far away, I would try for something to have afterwards."
Hammett died in Lenox Hill Hospital, in New York City, on January 10, 1961, of lung cancer, diagnosed just two months before. As a veteran of two world wars, he was buried at Arlington National Cemetery.
Hammett's relationship with Lillian Hellman was portrayed in the film Julia. Jason Robards won an Oscar for his depiction of Hammett, and Jane Fonda was nominated for her portrayal of Lillian Hellman.
Hammett was portrayed semi-fictionally as the protagonist in the film Hammett.