The night that ended with a fatal shooting at a Boulder restaurant started with an accidental text message, court documents state.

Christopher King, 49, was shot to death just after midnight on May 29 at the Bramble and Hare on the Pearl Street Mall. Louis Sebastian, 32, is charged with first-degree murder in the killing.

An affidavit released Thursday paints the picture of a tense night that ended in gunfire.

RELATED: Suspect, victim named in fatal shooting on Pearl Street Mall

RELATED: Man fatally shot after argument at Pearl Street Mall restaurant

King was invited to the party, thrown by a woman he used to "hook up" with, on accident. Documents state the woman thought she was texting another friend, but extended the invitation to King anyway.

The co-host of the party invited Sebastian because he "needed to invite more people" and Sebastian lived nearby. Sebastian, however, made the co-host nervous because he "often talked about interactions with the 'mob.'"

Sebastian and the woman were "flirting and kissing" at the party and continued to hold hands when the group went to dinner at Bramble and Hare around 9 p.m.

Heated arguments between Sebastian and King, sparked in part by politics, flared up a few times throughout the dinner. It came to a head when the group got the check and the table was $100 short. At this point, both men discussed taking the fight outside.

According to one witness's account, a few seconds after the pair went outside, shots were fired.

A chef at the restaurant told police he heard gunshots fired outside and confronted Sebastian as he came back into the restaurant and continued to shoot King, who a witness said was asking Sebastian to stop. At this point, the chef (who was in the Marine Corps for five years) tackled Sebastian and was able to disarm the gun -- a Sig Sauer compact semiautomatic 9mm handgun.

When police arrived, they found Sebastian held by the restaurant manager in a full nelson. The manager told police Sebastian said, "He attacked me. I'm done."

King was taken to a nearby hospital where he later died.

Detectives found eight shell casings at the scene.

Sebastian was formally charged Thursday morning with one count of murder in the first-degree and one count carrying a concealed weapon. His preliminary hearing is scheduled for August 7 at 9 a.m.

He did not have a criminal history before this.