Great Khagan Ahmed

Ibrahim ibn Ahmed.
This may refer to events related to the struggle of the great khan Ahmed, the head of the Eastern Karakhanids, against the Karakhanids in the first half of the 12th century, the creation of the Kyrgyz unions of the right — Ong and left — Sol wings, the defeat of the Karakhanids who invaded the territories of the Eastern Karakhanids, and his death.
The great khan Ahmed defeated the Karakhanids in 1128. In 1127, according to the "Majmu' al-Tawarikh," he created a union of Kyrgyz tribes of the right — Ong and left — Sol wings, i.e., before their struggle with the Karakhanids. According to historical data, khan Ahmed died after the defeat of the Karakhanids, who then retreated. After his death, power in the Eastern Karakhanid khanate passed to his son Ibrahim. The latter could have undertaken the "Great Campaign" to Beijing (Beshbalyk). Then Ibrahim perished.
Sources refer to him as a "shahid" (a term used for those who died for the faith (of Islam)). It is evident that khan Ahmed appears in these accounts under the name of his son — Ibrahim, to whom power passed after the father's death, which is why in the aforementioned information from "Majmu' al-Tawarikh" we find Ibrahim ibn Ahmed. The author of this work dates these events to the regions of Fergana, which is a product of his imagination and creative processing of various local data influenced by later events. This generally applies to many narratives in this source, allowing researchers to characterize "Majmu' al-Tawarikh" as a semi-historical, semi-legendary work, "in which historical facts and dates are intertwined with legends and fiction."
O. Karaev also suggested linking the imam Ibrahim mentioned in "Majmu' al-Tawarikh" with the head of the Eastern Karakhanids, Ibrahim ibn Ahmed. He wrote that "regardless, Imam Ibrahim is a historical figure, and he can be identified with the aforementioned Karakhanid ruler Ibrahim ibn Ahmed. By the way, the date of his death (1136), indicated in "Majmu' al-Tawarikh," is close to historical reality." These same statements are then repeated by him in another work. Indeed, the date of the death of Imam Ibrahim (1136), indicated in "Majmu' al-Tawarikh," is close to historical reality. However, in the case of Imam Ibrahim and the aforementioned information from "Majmu' al-Tawarikh," it is likely that we should see Ahmed, the father of Ibrahim, and events related to him. The date of death and the name may only refer to Ibrahim ibn Ahmed here.
“Majmu' al-Tawarikh” on the Twelfth Century
In "Majmu' al-Tawarikh," it is stated that Imam Ibrahim ibn Ahmed "...made Lur-khan the sardar of the right wing, and Lur-Buzurg the sardar of the left wing ... When Imam Ibrahim reached Kasan, Gurkhan came out with an army and prepared for battle. The Imam arranged the battle lines: he placed Lur-khan on the right wing and Lur-Buzurg on the left wing. The warriors engaged in battle; they fought for a day, the battle became fierce, and they surrounded Gurkhan. The Kalmyks, having captured Gurkhan, fled. The Imam took Kasan and made it a city of Islam. After this, he sent a man (with an army) to Jidghil: they captured Murghab, Furgab, and Dungal. Gurkhan, having retreated to Ming-Dzhubu, joined the Chingans (the Khitans), took the army of the Khitans, and went to Khitai ... he named the right wing (Imam Ibrahim — E. u. K.) Ong, and the left — Sol. The creation of the right (and) left wings among the Kyrgyz was the work of Imam Ibrahim (ibn Ahmed — E. u. K.) Sultan Zarandzhisha. (This) was in 521 (1127 AD), ... And when 96 years of his blessed earthly existence had passed, he said: "Go, bring ... They brought ... the sons of Anal-Hakk Lur-khan (and) Lur-Buzurg, they brought Mogol Ahmad-bek, ... (Imam Ibrahim) had one banner made of a white horn. Tying (it) with a white flag (or battle standard (note there) — E. u. K.) he gave (it) to Ahmad-bek Mogol ... After reciting a prayer for the murids and devoted servants, (Imam Ibrahim) died on the night of the 27th (day) of the month of Ramadan 530 (June 29, 1136) ..."