Only a few hundred years earlier Islam had a golden age, while Europe was in the dark ages. What led to the swap of power from one to the other?
Before my post, I just wanted to state that your timeline is rather off. Islam's golden age was well passed by 1300, being ended a century earlier by the Mongol conquests.
Essentially, Islam recovered by 1500 in the form of the Ottoman Empire. Stretching from the Balkans to Persia, this empire was largely built upon technological advances from the east, specifically China. Gunpowder was used to great effect by the Ottomans to conquer their less advanced neighbors.
This technology also allowed incursions into Europe, and until 1529 they were largely unstoppable. However, Suleiman the Magnificent, the Sultan of the Empire, was defeated by the Austrians in the siege of Vienna. This paved the way for a European strike against the Ottomans, causing them to lose much of their Balkan holdings in the Great Turkish War.
Ottoman power was declining from this point, but still strong, until the Battle of Vienna in 1683. This battle was the culmination point of Ottoman hegemony in central Europe, being replaced by the Hapsburg dynasty in Austria and opening them up further defeats. This battle was one that clearly put world power in the hands of Europeans, and was important in stopping Muslim power from again threatening Europe as it had in the past.
While this had been going on, Europe, specifically England, France and Iberia had colonized the Americas and parts of the Pacific. This made them rich and bountiful empires, eventually leading to the supremacy of western culture and power throughout the world. The industrial revolution further increased their supremacy, and North Africa was conquered by the French, Iberians and English.
The "Great Game" between England and Russia was a diplomatic match they both tried to outdo each other in by bringing Asia into their respective spheres of influence. This was made possible by European supremacy, resulting in Afghanistan going to England and Persia split between them.
Finally, the collapse of the Ottoman Empire in World War One allowed France and England to take control of the middle east, essentially leaving only Turkey independent from Europe, with Iraq and Afghanistan dependent on Europe and Persia in a precarious position.
I don't know that the change was as sudden as you are thinking. I can only speak for Anglophonic influence in Afghanistan, but I'm unfamiliar with any instances of significant colonization in the Middle East occurring before the 1700s (which would be something like 3 or 4 centuries after the Islamic golden age). To speak in the most general terms, the entire region has a long history of conflict due to its position as a crossroads between Europe and the resource-rich East.
British interest in the region was chiefly centered upon the economic significance of India, and the fear that Russian involvement in and around Afghanistan (the so-called Great Game) would leave the "Crown Jewel of the Empire" vulnerable to invasion. The discovery of oil during the 1930s would ensure the region remained immersed in conflict for quite some time.
I will begin by discussing the Great Game; Britain was a maritime empire, hugely reliant on trade and imported raw materials. British firms would buy raw materials overseas (usually in one of Britain's many colonies), sail back to England, and sell the goods to factories. Factories then refined the products, and exported the finished goods back to British colonies and other international markets. Value-added industry in this "triangle of trade" is something you may have read about in your high school textbooks.
The British East India Company (then known as the English East India Company) began establishing trade routes in India as earlier as 1608, seeking to buy raw materials and luxury goods. Colonial rule of British India is a topic in its own right, but by the 1870s, India was a colony of the Empire. It was also a considerable source of revenue due to the nature of the British economy.
During this time, the British military became concerned with Russia's growing influence in the region. The fear was that Russia would subdue the Khanates in Central Asia one-by-one before launching an invasion of India via Afghanistan. Seeking to counter Russian influence, the British invaded Afghanistan in the late 1830s, fighting for around 3 years before being expelled by the Afghans in 1842.
The British returned in the late 1870s and defeated the Afghans two years later. They withdrew at the end of the war, but would control Afghan foreign policy by way of a considerable subsidy for a period lasting just under 40 years. British influence largely dissolved after the Afghans defeated the Empire during the third Anglo-Afghan war. Thereafter, oil became the primary motivation of foreign intervention within the region, with Anglophonic firms in particular (both English and American) putting forth a considerably violent effort to secure their oil supply.
Not a detailed answer but it was the fall of the Ottoman empire after WWI. The Ottoman empire had been in a state of decline for decades but were still pretty powerful. They sided with Germany and the other Central powers and defeat was the final blow to the integrity of the empire. After WWI the victorious Britain and France carved up most of the empire, though the Turks were able to hold on to Anatolia. Of course there are plenty of details I've left out since it's 4 AM.