In the popular imagination, Mexican drug cartels — like Mafia families or major corporations — are sometimes thought of as stable entities that have lasted for decades. While bosses may come and go, many believe the basic structure of cartels, and the names associated with them, remain unchanged.

But a month of testimony at the trial of Joaquín Guzmán Loera, the Mexican kingpin known as El Chapo, has suggested the cartels are less like the Gambinos or General Electric and more like something out of “Game of Thrones.” Cartel leaders have not only shifted frequently over the years, but the groups themselves have also changed shape in an almost constant series of alliances and breakups.

According to the several witnesses at the trial, Mr. Guzmán started in the trafficking trade in the late 1980s while working under the wing of a more senior crime lord, Juan José Esparragoza, who ran what was known as the Guadalajara drug cartel. At the time, Mr. Guzmán was surrounded by a modest entourage of family and friends: his brother, Arturo, known as El Pollo (Spanish for “the chicken”); his cousins, the three Beltrán-Leyva brothers; and his first employee, a pilot named Míguel Angel Martínez.

Almost from the start of his career, Mr. Guzmán had trouble with the Tijuana drug cartel, which controlled most smuggling operations at the Mexican border with San Diego. Eventually, a war broke out with the Tijuana traffickers when Mr. Guzmán, disobeying protocol, got caught moving cocaine through their turf without permission.