On August 17, 986 Samuel defeats the Byzantines at the Battle of Trajan's Gate. The Byzantine emperor Basil II suffered the greatest defeat in his campaigns to conquer Bulgaria. A significant part of his army is destroyed, and he barely manages to save himself.
Before finally deciding on military action, Basil II made an attempt to come to an understanding with the Bulgarians. In this context, he conducted negotiations with Aaron, the eldest of the remaining living komitopuli, with the aim of bringing discord between him and Samuel. In exchange for his submission, Aaron wanted to establish kinship ties with the emperor by marrying one of his sons to Anna, Basil II's sister. Instead of his sister, the emperor sends another bride to Aaron. When the Bulgarians discover the deception, there is a breakdown in the negotiations and the emperor leads his army against them.
Basil II marches with an army numbering up to 30,000 men. From Adrianople (now Edirne), the emperor reached Philipopol (now Plovdiv), and from there he went to Serdika (now Sofia). His goal is to deal with the Bulgarians with one blow.
After the capture of Serdika, which, in addition to being the center of the Aaronic dominions, is also a strategic point between the northeastern and southwestern Bulgarian lands, Basil II planned to continue his campaign against Samuel in the southwest towards Macedonia.
On his way to Serdica, around the pass of Trajan's Gate, the emperor left a strong detachment led by the general Leo Melisinus with the task of guarding the rear of the main army. Reaching Serdica, Basil II surrounded it and built a heavily fortified camp.
Basil II found only about 4,500 defenders in the fortress, as Samuel was on a campaign with troops in Thessaly (Central Greece). This seemingly eases his task, but forces him to hurry before Samuel returns.
Samuel's troops arrived at the Sofia field with an extremely fast march and settled under Vitosha in the area of today's Bistritsa village in a fortified camp. From there they launched surprise attacks against the Byzantine troops who were roaming the Sofia field for food and fodder. Thus, instead of the Romans starving the besieged, they began to starve themselves.
The siege drags on for 20 days. The Byzantine emperor headed back to Philippopolis again through Trajan's Gate. Samuel does not go after him on his heels, but applies “parallel pursuit” from Bistrica through Dolni and Gorni Passarel south of Lozenska Planina, in order to enter the Ikhtiman Field before the Byzantine troops and prepare their ambush.
The Byzantine army retreated from the Sofia Field to Shtipon (now Ikhtiman), where it spent the night. The rumor that the Bulgarians were blocking the surrounding mountain roads caused a commotion among the soldiers, and the next day the retreat continued in increasing disorder. Seeing this, the Bulgarians, led by Tsar Romanus, Aaron and Samuel, descended on the Byzantines, captured their camp and turned their retreat into flight.