A 13-year-old girl with special needs was beheaded because she saw her grandmother murdered in a cemetery, a US court has heard.

Mariah Lopez was killed after her grandmother reportedly went to buy drugs but the deal turned into an argument.

The teenager saw how her grandmother was attacked with a knife by her live-in boyfriend and left to die on the ground, testimony revealed.

Israel Palomino, 34, and Yoni Aguilar, 26, are charged with two counts each of murder – punishable by the death penalty.

Ms Lopez’s family wept in Madison County Court court as details of the case were related.

The grandmother, Oralia Mendoza, 49, was linked with the Sinaloa cartel, a drug-trafficking organisation, a Madison County sheriff's investigator said.

The killings happened after Palomino, Aguilar, Ms Mendoza and a woman named Leticia Garcia went to pick up a batch of methamphetamine in Georgia, authorities said. The two women were linked to the cartel, and Palomino suspected there might be a set-up, investigator Stacy Rutherford told a judge.

Two days later Palomino and Aguilar drove Ms Mendoza and her granddaughter to the cemetery in Alabama. Ms Mendoza and Palomino got out of the car and argued about the drug deal, according to Aguilar's account, recounted in court.

Aguilar told police the argument escalated, and Palomino killed Ms Mendoza. Authorities have said her cause of death was “sharp force trauma caused by a knife”.

Because Mariah was a witness, the suspects took the girl to a secluded area nearby, Ms Rutherford said.

Aguilar said in his statement that Palomino forced him to kill the girl, telling investigators he was holding the knife when Palomino came up to him and moved his arm back and forth in a sawing motion. Mariah was beheaded, Ms Rutherford told the court.

Aguilar was said to be afraid of Palomino.

The details emerged during a preliminary hearing for Aguilar, when the district judge ruled prosecutors had enough evidence to send the case to a grand jury. Palomino's case is set for preliminary hearing tomorrow.

Investigators recovered two knives, believed to be the murder weapons. One was found under Aguilar's mattress; the other was under Palomino's mattress.