Now, this is indeed a little bit of a big question and the underlying assumption that ‘third world’ nationalism and anti-colonialism can be generalised is something I disagree with a lot. Even in the Middle East alone you have a vast array of different nationalisms competing with each other, from Armenian to Turkish nationalism, or the much more ambitious Arab nationalism, sometimes synonymous with pan-Arabism (though they are not one and the same). Since my ‘expertise’ and I use the word expertise lightly lies mostly with the modern Middle East, I will attempt to answer your question through that lens. And I think that modern Arab nationalism is mostly the result of anti-colonialism. I apologise in advance if this does not quite answer your question, but a Reddit comment in my opinion cannot do justice to such a broad question, incorporating many different nationalisms in the third world. It could potentially even be written into a monograph. Anyhow, let’s get into it.
Arab nationalism is unique in the fact that it is not so much ethnically based (as say Turkish nationalism) as it is linguistically based. There are a lot of cultural and, contrary to popular belief, even religious diversity in the Arab world. There are 22 countries that could potentially be identified as Arab (based on membership of the Arab League), but the extent of that is a question for another time. Because of this unique background, it is already clear why a pan-Arab state is much harder to achieve due to its ambition than say Turkish nationalism, which was focused on a smaller population and only one country.
The origins of Arab nationalism are still debated, but both sides almost always argue that modern Arab nationalism is to a high degree a result of anti-colonialism. Antonius (author of the Arab Awakening, which I have yet to read) and the ‘classical school’ popularised the idea of Arab nationalism being rooted in the 19th century, under Ottoman rule. There is a lot to be said about Ottoman rule over the Arabs, but there was some civil strife here and there, and the gripes with Ottoman policies. There were some revolts from the Arab world against Ottoman rule, most notably that of Muhammad Ali of Egypt and the Sauds in the Arabian Peninsula. Now this was indeed a resistance of some sort to rid their states of Ottoman influence, but it was not informed by Arab nationalism. Muhammad Ali was Albanian, not Arab, and the Saudi revolt was more informed along religious lines than Arabic lines. The true change came after the Young Turk Revolution of 1908 however, despite initial optimism the Young Turks promoted Turkish over Arabic and overall cracked down on any illegal political activity, further agitating the Arabs. Now while Arab nationalism was not quite there yet, you can see the trend that resistance in the Middle East and the development of Arab nationalism pre-WW1 is very much informed by anti-imperial sentiments among the population.
On the other side of the debate are the ‘revisionist’ scholars, such as Adeed Dawisha, arguing that Arab nationalism started to take a real form after WW1 and thus excludes the Arab Revolt. The idea is that during the 19th century, most Arab identified by religion first and foremost rather than ethnicity or any other identity, which was secondary. Arab nationalism seemed to mostly be present among Arab intellectuals attached to institutions such as the American University of Beirut. In the following WW1, Europe took control over large parts of the Middle East through the Mandate system and we have the infamous Israeli-Palestinian conflict. It is important to note it was still predominantly an Arab-Israeli conflict at this point, and the Palestinian identity is another debate entirely. Key thinkers during the inter-war era includes Sati al-Husri, who borrowed nationalist ideas from Europe and hoped to turn Iraq into the ‘Prussia of the Middle East’. But this was a difficult task all around. Iraq in general symbolised the problems with European colonialism and the difficulties of Arab nationalism; it was a state cobbled together through artificial means, with Shi’ite Arabs, Kurds (who are not related to any Arabs except through religion), dominated by the smaller Sunni Arabs. Shi’ites perceived Arab nationalism as a Sunni project and Kurds had no interest in it for obvious reasons. So even here in Iraq one can see clearly that despite the difficulties, Arab nationalism started to take shape as an answer against colonial rule.
To jump forward to the 1950s, Arab nationalism reached its peak during Gamel Abdel Nasser’s reign, started following the July Revolution of July 23, 1952, in Egypt. Nasser was a noted anti-imperialist and republican, but most notably an Arab nationalist and he envisioned a unified Arab state. His nationalism was intrinsically tied with nationalism, with his early reign marked resisting British imperialism. He secured full independence for Egypt for the first time in over a century and he (and Arab nationalism) reached a peak in popularity when he nationalised Suez Canal and removed the British and French from Egypt permanently in October-November 1956. It reached a peak during the Arab United Republic with Syria, formed in 1958. This would already fail by 1961, however. This popularity would end following the Six Day War against Israel, whom Nasser saw as a product of imperialism and a colonial power itself. But again Nasser, and all the events I just described are much more complicated and deserve a full question and answer themselves.
Though still discussed, in the modern day Arab nationalism is mostly 'dead' having been replaced in large parts by more local nationalisms such as Syrian or Iraqi nationalism, or pan-Islamism.
So, to conclude, it is evident that the development of Arab nationalism developed along anti-colonial lines and it would never have had the significance it did if it was not for the colonial occupation of Middle Eastern country. So to answer your question; Arab nationalism is a product of anti-colonialism more so than the other way around.
Bibliography
Aziz, M.A. "The Origins of Arab Nationalism." Pakistan Horizon 62, no. 1 (2009): 59-66. Accessed May 8, 2021. http://www.jstor.org/stable/24711051.
Gershoni, Israel. Review of Arab Nationalism in the Twentieth Century: From Triumph to Despair, by Adeed Dawisha. International Journal of Middle East Studies. August 9, 2006.
Kramer, Martin. "Arab Nationalism: Mistaken Identity." Daedalus 122, no. 3 (1993): 171-206. Accessed May 8, 2021. http://www.jstor.org/stable/20027188.
Rogan, Eugene L. The Arabs: A History. 3rd ed. London: Penguin Books, 2018.
Shlaim, Ali. "The Rise and Fall of Arab Nationalism". Review of Arab Nationalism in the Twentieth Century: From Triumph to Despair, by Adeed Dawisha. The Guardian. March 29, 2003.