It might have seemed like it came out of nowhere when Saudi Arabia and its allies blockaded Qatar and President Trump accused it of supporting terrorism even though it’s an ally. But this all makes a lot more sense when you see that Qatar and Saudi Arabia have been rivals for 20 years. Their competition plays out across the whole Middle East and helps to explain the region’s chaos. Qatar is this tiny country that, starting with its independence just in 1971, was dominated by the more powerful Saudi Arabia. No country likes to be dominated by a neighbor, even if they both speak Arabic, export energy and have Sunni monarchies. Qatar decides it has to rival Saudi Arabia if it wants autonomy, and it has some advantages. It makes friends with everybody. It opens trade relations with Israel. It improves relations with Iran, which is Saudi Arabia’s archrival. It hosts a United States air base. It starts a satellite network, Al Jazeera, to project soft power in the region. But most important, it gets really rich by exploiting huge natural gas reserves. The emir travels around the Middle East and the world, meeting with leaders, brokering peace talks, and throwing money around. The Saudis are not happy, but to some degree they come to accept Qatar’s independence. But then the Arab Spring happens. Popular uprisings spring up across the Middle East, in some places toppling governments or inciting civil wars. For Qatar, it’s an opportunity, because most Arab autocrats are aligned with Saudi Arabia. It backs the uprisings with Al Jazeera airtime, diplomatic support and, later, money and sometimes guns. But Saudi Arabia feels threatened by the uprisings. So each time a power vacuum opens, they both rush in. In some places, like Tunisia, Saudi Arabia and Qatar each back opposing political parties. In Libya, they arm rival groups who will later fight a civil war. Their worst rivalry is in Egypt. Qatar backs the Muslim Brotherhood. But Saudi Arabia backs the Egyptian military, which takes over. Qatar’s big campaign began to collapse in 2013. Its allies faced mounting losses. The emir stepped down, passing power to a young son with less experience. Last month, President Trump received a warm welcome when he visited Saudi Arabia. Less than two weeks later, the Saudis announced the blockade. It’s not clear exactly what led to the move, but President Trump surprised everybody when he went after Qatar on Twitter Qatar’s economy and security are now in peril. The huge United States air base was supposed to be a guarantee against getting bullied by the Saudis, but it did not work. The Saudis took a big step toward reasserting control over the region, which means promoting friendly autocrats and opposing Iran. For the United States, opposing Qatar seemingly overnight sends a troubling message to other allies. Will President Trump turn on them next?