The killing of Joseph and Hyrum Smith is a complex historical event with many contributing factors. The following timeline contains the relevant information you need to understand the unfolding of these events.
Events leading up to the martyrdom of Joseph and Hyrum Smith
1844, Hancock County, Illinois
William Law, Wilson Law, Robert Foster, and other critics of Joseph Smith are excommunicated from the Church for "unchristianlike conduct."
The “True Church of Jesus Christ of Latter-Day Saints” is organized with a former member of the First Presidency, William Law, as president.
The first and only edition of the Nauvoo Expositor is published in Nauvoo, criticizing Joseph Smith and publicizing details about plural marriage.
The Nauvoo City Council rules that the Nauvoo Expositor is a "public nuisance" and should not be allowed to continue publication.
June 10 (contd.)
Francis Higbee, who was involved in the publication of the Expositor, swears a complaint against Joseph Smith and the Nauvoo City Council in the Hancock County seat of Carthage, Illinois.
June 12 (contd.)
Joseph obtains a "writ of habeas corpus", which allows the Nauvoo Municipal Court to hold the hearing in Nauvoo where they discharge Joseph the same day.
Joseph Smith presides as Mayor and Chief Justice at another hearing of the Nauvoo Municipal Court, where the remaining 17 individuals named in the warrant are discharged.
June 13 (contd.)
In response to Joseph Smith dismissing the charges, citizens in nearby Warsaw and Carthage hold meetings and pass resolutions demanding that Joseph must answer to the law, otherwise a "war of extermination should be waged."
These resolutions are published and the date of June 19, 1844 is announced for vigilantes to invade Nauvoo to arrest Joseph Smith.
June 16 (contd.)
A Hancock County Circuit Court presiding judge travels to Nauvoo and advises that Joseph should submit to a third hearing over "inciting a riot" outside of Nauvoo.
Joseph Smith declares martial law in Nauvoo and mobilizes approximately 3,000 men, the Nauvoo Legion, “to preserve the city and the lives of its citizens."
June 22 (contd.)
Ford writes to Joseph Smith, demanding that he stand for yet another retrial of the riot charge in Carthage.
June 23 (contd.)
June 25 (contd.)
Constable Bettingsworth takes Joseph and Hyrum into custody on a separate charge of “treason against the government and the people of the State of Illinois” in relation to the declaration of martial law in Nauvoo on June 18.
Governor Ford meets with Joseph Smith in jail, where Joseph says he is willing to stand trial for the treason charges before "any other Justice" besides Robert F. Smith; Ford denies the request and once again promises to keep them safe.
June 26 (contd.)
The trial over the treason charges is postponed by Robert F. Smith until June 29, and the charged men are to remain incarcerated until then.
June 27 (contd.)
How did Joseph and Hyrum Smith die?
Why were they in jail?
They were arrested on June 25, 1844 on charges of “treason against the government and the people of the State of Illinois”. The charges were based on Joseph Smith's declaration of martial law in Nauvoo on June 18. Threats of violence had been made against the Latter-day Saints, and Church leaders were intent on ensuring the safety of the citizens of Nauvoo.
Were they guilty of treason?
Probably not. Illinois law at the time defined treason as “levying war against the government and people of this state” or “giving . . . aid, advice, and comfort” to any enemies of the state. The Nauvoo Legion, a state-authorized militia,[BIO] was mobilized for approximately four days, during which they detained several people who were not Nauvoo citizens, but no record exists to suggest war or violence were perpetrated against the state of Illinois or its citizens.
Weren't they jailed because they destroyed the Nauvoo Expositor?
No, but it is related. Joseph and Hyrum were already in Carthage for a retrial of charges for "inciting a riot" from two weeks earlier when Joseph ordered the destruction of the Expositor, a local newspaper critical of Joseph Smith. These charges were the result of complaints by disaffected Latter-day Saints who had funded and published a single edition of the Expositor that "exposed" Joseph Smith's polygamy, claimed he was unjustly accumulating power, and was an "apostate" introducing false doctrines into the Church. See timeline above for more information relating to the publishing and destruction of the Expositor.
Is it true that Joseph and Hyrum attempted to flee after the riot hearings?
Yes. Citizens of Hancock County had met and published a resolution threatening "a war of extermination. . .to the entire destruction, if necessary for our protection, of [Joseph's] adherents". Joseph and Hyrum fled to Iowa on June 23, but stayed for less than a day when they learned that some Latter-day Saints felt betrayed, and there was still the possibility of violence in Nauvoo.
Is it true that Joseph and others took off their garments before going to Carthage?
Yes. In a meeting in 1845, John Taylor stated that Joseph, Hyrum, and himself had removed their garments prior to traveling to Carthage, while Willard Richards had not. W. W. Phelps[BIO] recalled in the same meeting that Joseph told him they removed their garments "on account of the hot weather."
Is it true that Joseph had a gun during the attack at Carthage jail and shot people?
Yes. Cyrus Wheelock[BIO] smuggled a gun into Carthage jail in his overcoat and gave it to Joseph. When the mob of armed men entered the jail to kill Joseph and his colleagues, Joseph fired back with a six-barreled pistol. Three men in the mob were reportedly wounded. Hyrum also had a gun, but it is unclear whether he fired it.
Did Joseph Smith call out a Masonic distress signal during the shooting?
If Joseph died in a "gunfight" in jail, should we be calling him a martyr?
The term "martyr" can refer to anyone who dies for a cause, but has its roots in the context of religion. Religious beliefs and practices were a significant source of tension between the Latter-day Saints and their fellow citizens, and Joseph and Hyrum were religious leaders. Several newspapers that covered their deaths labeled them as martyrs.
Doesn’t a true martyr have to willingly go to their death?
No, not historically. For example, Stephen in the Bible is often referred to as the first martyr, and he did not volunteer to die.
Foxe’s Book of Martyrs, first published in 1563, includes many Christian martyrs who tried to escape, fought back, and even killed those trying to kill them. Those considered Latter-day Saint martyrs by the time of Joseph's death included some like David Patten,[BIO] who fought their attackers, and some who did not fight, such as women and children, or even those who died long after the Missouri violence against the Latter-day Saints.
Joseph said that he was "going as a lamb to the slaughter." Is that a misrepresentation?
Joseph surrendered to authorities in Carthage to stand trial and expressed concern multiple times that violence or even death were possible if he went, despite the pledge of protection from Governor Thomas Ford.
Has the Church tried to control the martyrdom narrative and exclude the part about him firing a gun at the mob?
Yes and no. The Church has published many narratives over the years describing the martyrdom of Joseph Smith and many of them have excluded the fact that he was armed or have implied that he was unarmed. However, many of them have also included this detail. The pepperbox pistol believed to be used by Joseph has been on display in the Church History Museum since 2015.
Did the Church have any traditions of vengeance for the martyrdom?
Yes. In 1889 it was reported that the temple endowment contained an "oath of vengeance" which required endowed members of the Church to "never cease" to pray that God would "avenge the blood of the prophets."
Additionally, the last line of the second verse in the original 1844 lyrics of the hymn “Praise to the man” originally read, "Long shall his blood, which was shed by assassins, stain Illinois, while the earth lauds his fame," but was later removed in the 1927 version of the hymnal.
I heard that some people think that Brigham Young or John Taylor killed Joseph Smith. What's that about?
There is no credible evidence in the documentary records to support this theory. However, in the Under the Banner of Heaven FX mini-series, there are multiple scenes that imply that Brigham Young ordered Joseph's death, and the film Who Killed Joseph Smith? presents a theory that blames John Taylor for the deaths.
So who was held accountable for the deaths of Joseph and Hyrum?
No one. Of the approximately 150-200 mob members, nine were indicted, and four fled the county to avoid trial, so only five people were brought to trial in The People v Levi Williams. Three of those who fled were reportedly injured by Joseph Smith when he fired back into the mob. In May of 1845, the defendants who actually went to trial were found not guilty. 
- Devenna M.
“I have studied the church history extensively and I believe Joseph Smith led the early church to the best of his ability. He was thwarted by non-members at every turn by their fear that with his popularity and charisma he might become President of the United States.”
- Jackie H.
“I believe Joseph Smith was a martyr who, when pushed to the limit, as any human would, protected himself and his brother, when they had gone to turn themselves in, and were attacked by the mob.”
- Mitch N.
“Sam Weston presented his research on this. He argues that Hyrum wasn't shot through the door, but from outside, since his death mask doesn't reveal any wood shards in his face, which would have left marks if shot at point blank range. He was in the middle of the room when shot.”
- Adam J
“Of course Joseph and Hyrum's count as martyrs. Calling the attack of four guys stuck in a jail cell with a pistol by like two hundred mobsters a gunfight is just ridiculous.”