Baptized on 13 December 1752 at Gosport, Hampshire, Hackman was the son of William and Mary Hackman. His father had served in the Royal Navy as a lieutenant. Hackman was apprenticed to a mercer, and although according to some accounts he became a member of St John's College, Cambridge, no record of this can be traced at Cambridge.
In 1772, Hackman was purchased a commission as an ensign in the 68th Regiment of Foot, and in 1776 was promoted lieutenant, but by early 1777 he had resigned from the army to become a clergyman. On 24 February 1779, Hackman was ordained a deacon of the Church of England and on 28 February a priest, and on 1 March 1779 was instituted as Rector of Wiveton, a place which he may never have visited.
In about 1775, while he was a serving army officer, Hackman visited Lord Sandwich's house at Hinchingbrooke and met his host's mistress Martha Ray. She was "a lady of an elegant person, great sweetness of manners, and of a remarkable judgement and execution in vocal and instrumental music" who had lived with Lord Sandwich as his wife since the age of seventeen and had given birth to nine of his children. Sandwich also had a wife, from whom he was separated, who was considered mad and who lived in an apartment at Windsor Castle. This was the same Lord Sandwich who is said to have called for a piece of beef between two pieces of bread, thus originating the word sandwich. He was a patron of the explorer Captain James Cook, who named the Sandwich Islands after him.
Hackman struck up a friendship with Martha Ray (who was several years older than he was) and was later reported to have become besotted with her. They may have become lovers and discussed marriage, but this is disputed. Although rich, Sandwich was usually in debt and offered Martha Ray no financial security. However, whatever was between Hackman and Martha Ray ended when he was posted to Ireland.
On 7 April 1779, a few weeks after his ordination as a priest of the Church of England, Hackman followed Martha Ray to Covent Garden, where she had gone to watch a performance of Isaac Bickerstaffe's comic opera Love in a Village with her friend and fellow singer Caterina Galli. Suspecting that Ray had a new lover, when Hackman saw her in the theatre with William Hanger, 3rd Baron Coleraine, he left, fetched two pistols, and waited in a nearby coffee house. After Ray and Galli came out of the theatre, Hackman approached the ladies just as they were about to get into their carriage. He put one pistol to Ray's forehead and shot her dead. With the other he then tried to kill himself but made only a flesh wound. He then beat himself with both discharged pistols until he was arrested and taken, with Martha Ray's body, into a tavern in St James's Street. Two letters were found on Hackman, one addressed to his brother-in-law, Frederick Booth, and a love letter to Martha Ray: both later appeared in evidence at the murder trial.
When Lord Sandwich heard what had happened, he "wept exceedingly".
On 14 April 1779, Martha Ray was entombed inside the parish church of Elstree, Hertfordshire, but her body was later moved into the cemetery. On the instructions of Lord Sandwich, she was buried in the clothes she had been wearing when killed.
Hackman was quickly committed to the Tothill Fields Bridewell. As "James Hackman, Clerk", he was indicted for "the wilful murther of Martha Ray, spinster" on the inquisition of the coroner.
On 16 April 1779, just nine days after the event, Hackman was tried for murder at the Old Bailey. Despite having previously decided to plead guilty, in the event he pleaded not guilty, explaining that "the justice of my country ought to be satisfied by suffering my offence to be proved".
John McNamara, Esq., gave evidence that on the evening of 7 April, he believed at some time after eleven o'clock, he came out of the playhouse with Martha Ray, and having seen her "in some difficulties at the playhouse", offered his help in handing her to her carriage. She took his arm. As they came out of the passage into the Covent Garden playhouse and were two steps from the carriage, he heard the report of a pistol, while Miss Ray was still holding his right arm with her left hand. She fell instantly. He thought the pistol had been "fired out of wantonness" and that Miss Ray had fainted. He knelt to help her, but found blood on his hands, and got her into the Shakspeare tavern. He did not see Hackman at the time, but after he had been arrested, asked him what had possessed him, and he answered "that it was not a proper place to ask that question, or something to that effect... I asked him his name, and I understood from him that his name was Hackman; I think he pronounced his name with an H. I asked him if he knew anybody. He said, he knew a Mr. Booth, in Craven-street in the Strand, and desired he might be sent for. He desired to see the lady. I did not tell him she was dead; somebody else did. I objected to his seeing her at that time. I had her removed into another room. From the great quantity of blood I had about me I got sick, and was obliged to go home. I know no more about it."
Mary Anderson, a fruit seller, gave evidence that she was standing close by the carriage. She is recorded as saying:
Anderson said she had identified Hackman in Tothill Fields Bridewell the next day and she did so again in court, pointing to the prisoner.
Richard Blandy, a constable, gave evidence that he had been coming from Drury-Lane house and that as he came by the piazzas in Covent Garden he heard two pistol shots and then heard somebody say two people were killed. Approaching, he saw the surgeon had Hackman and a pistol in his hand. A Mr Mahon had given Blandy the pistol and asked him to take care of the prisoner and to take him to Mahon's house. The prisoner was bloody, wounded in the head, and very faint. When Blandy came to the corner by the Red Lion, the door was shut, and he was then asked to take the prisoner back to the Shakspeare tavern, where Mr Mahon was. Blandy searched the prisoner's pocket and found two letters, which he gave to Mr Campbell, master of the Shakspeare tavern. He could say nothing else about the letters.
James Mahon, an apothecary, gave evidence that he lived at the corner of Bow Street. Coming through the piazzas in Covent-Garden, he heard two pistols go off. Going back, he saw a gentleman lying on the ground, with a pistol in his left hand, beating himself violently and bleeding copiously. The prisoner was the gentleman. Mahon had taken the pistol away from him and given it to the constable, asking him to take the prisoner to his house for the wound to be dressed. He had seen nothing of the lady until two or three minutes later he saw her lying at the bar, with a mortal wound, and said he could not help her.
Dennis O'Bryan, a surgeon, gave evidence that he had examined Miss Ray's body at the Shakspeare tavern on the night of the murder. He found the wound to be mortal, could find no sign of life, and pronounced the woman dead. The wound was in the 'centra coronalis' (the crown of the head) and the ball had come out under the left ear.
Hackman gave evidence for himself, reading a prepared statement to the court, which was probably written by the lawyer and writer James Boswell, who although not professionally engaged was closely associated with the defence. The statement afterwards appeared in all the newspapers. Hackman admitted that he had killed Ray, but he claimed he had only meant to kill himself. He said:
Hackman's defence counsel submitted to the court that Hackman was insane and that the killing of Martha Ray was unpremeditated, as shown by the letter to her found on him.
William Halliburton was sworn and produced the other letter found in the prisoner's pocket, which he said he had had from Booth. Mahon identified it as a letter taken from the prisoner, which he said Booth had opened and read in his presence. The letter, addressed to "Frederick Booth, Esq. Craven street, in the Strand", was read into the record:
Mr Justice Blackstone, presiding at the trial, summed up the case against Hackman. He told the jury that the crime of murder did not demand "a long form of deliberation" and that Hackman's letter to Frederick Booth showed "a coolness and deliberation which no ways accorded with the ideas of insanity". Hackman was convicted and sentenced to be hanged.
In a newspaper report of the trial, Hackman was described as five feet nine inches tall, "very genteely made, and of a most polite Address".
After the trial, James Boswell told Frederick Booth that Hackman had behaved "with Decency, Propriety, and in such a Manner as to interest everyone present".
Hackman was hanged at Tyburn on 19 April 1779. He travelled there in a mourning coach, accompanied by the sheriff's officer and two fellow clergymen, the Rev. Moses Porter, a curate friend from Clapham, and the Rev. John Villette, the chaplain of Newgate Prison. James Boswell later denied rumours that he had also been in the coach.
At Tyburn, "Hackman... behaved with great fortitude; no appearances of fear were to be perceived, but very evident signs of contrition and repentance". His body was later publicly dissected at Surgeons' Hall, London.
Hackman's case became famous, and The Newgate Calendar later noted that:
Horace Walpole remarked that the murder fascinated much of London during April 1779. At first, given Sandwich's position as First Lord of the Admiralty, a political motive was suspected. Not long before, Sandwich and Martha Ray had found themselves fleeing from Admiralty House, where a mob was rioting against the government and in particular against what it saw as the mistreatment of Admiral Keppel.
The affair inspired Sir Herbert Croft's epistolary novel Love and Madness (1780), an imagined correspondence between Hackman and Martha Ray. In this, Hackman is dealt with sympathetically. He is represented as a man of sensibility suffering from an extreme case of unrequited love who descends into suicidal and homicidal despair, even to the point that the reader is invited to identify with Hackman rather than with his victim.
Samuel Johnson and Topham Beauclerk debated whether Hackman had meant to kill only himself. Johnson believed that the two pistols Hackman took with him to Covent Garden meant that he intended there to be two deaths. Boswell himself (who had visited Hackman in prison) wrote that the case showed "the dreadful effects that the passion of Love may produce".
In his Mind-Forg'd Manacles (1987), the social historian Roy Porter argues that Hackman was well aware of the madness of his passion.
In The Luck of Barry Lyndon, Thackeray has his protagonist describe having met Hackman 'at one of Mrs Cornely's balls, at Carlisle House, Soho'.
A mezzotint of Hackman by Robert Laurie, after Robert Dighton, was published in 1779. Another engraving of Hackman (artist unknown) was used as an illustration in The Case and Memoirs of the Late Rev. Mr James Hackman (1779).