In 1860s, the relations between Qatar and Bahrain deteriorated with a series of small disputes. Hostilities emerged when, in 1867, Bahrain arrested a Qatari Bedouin in the Qatari mainland and deported him to Bahrain. In response, the Qataris, led by the Naim tribe, defeated the Bahraini army that was based on the peninsula, effectively expelling them. These tensions led Bahrain, allied with Abu Dhabi, to attack Qatar. The conflict failed to pacify and resulted in an escalation between the two parties in the following year. In October 1867, the Bahraini Hakim Mohammed al Khalifa, sent his brother, Ali Al Khalifa, with a force of 500 men in 24 boats to attack Qatar. He was joined by a force of 200 men under Ahmed al Khalifa. Additionally, Bahrain's ally Abu Dhabi sent 2,000 troops in 70 boats. The attack on Qatar led to the sacking of Bida  and Wakra. A British record later stated "that the towns of Doha and Wakrah were, at the end of 1867 temporarily blotted out of existence, the houses being dismantled and the inhabitants deported". A Qatari counterattack followed the next year, resulting in the destruction of most of the Bahraini naval vessels deployed. The 1868 attack resulted in some 1,000 individuals killed and 60 ships destroyed.

Based on the above article, answer a question. What happened firts, the defeat of the Bahraini army, or Bahrain's attack on Qatar?
defeated the Bahraini army