Prosecutors in the US trial of Joaquin “El Chapo” Guzmán have shown jurors text messages they said the accused Mexican drug lord sent to his wife and apparent mistress in which he discussed narrowly escaping from a raid and joked about arming his 18-month-old daughter with an assault rifle.

The messages from early 2012 were read by FBI special agent Steven Marston, on his second day testifying in Brooklyn federal court.

Marston explained US authorities were able to obtain them by searching records collected by a spy software Guzmán himself had ordered installed on phones used by his wife, Emma Coronel, and by another woman, Agustina Cabanillas.

Guzmán was extradited to the US in 2017 to face charges of trafficking cocaine, heroin and other drugs into the country as leader of Mexico’s Sinaloa cartel.

The texts appeared to show Guzmán and Coronel discussing the hazards of cartel life. In one message, Coronel said she was being watched by law enforcement, Guzmán advised her to “live a normal life”. In another, Coronel assured her husband she had a gun.

After a raid on a house in the Mexican beach resort of Los Cabos that captured several of his associates, Guzmán told Coronel he escaped through a window with a few scratches, according to the texts.

Coronel watched the testimony impassively, though she appeared to become uncomfortable when Marston began reading romantic texts purportedly between Cabanillas and her husband in which she called him “love”.

The texts appear to show Cabanillas acted as a go-between in the drug business, helping to set up deals between Guzman and various other people, including one who used the name “War Princess” and another who went by a series of emoticons.

Some of the messages appear to show heartfelt affection from Guzman amid the talk of guns and drugs, particularly for his twin daughters, Emmely “Mali” and Maria Joaquina “Kiki” Coronel, then about one and a half years old.

“Our Kiki is fearless,” he told Coronel, according to the texts. “I’m going to give her an AK-47 so she can hang with me.”