In the past week, Morocco’s decision to send planes loaded with food to Qatar has been criticised in light of the internal problems the North African country has recently been facing. People accused the Moroccan government of trying to aid a foreign country before responding to the grievances of its own people. Such a critique, however, is superficial and fails to take the historical context of regional relations and Morocco’s foreign policy ambitions into consideration.

Certainly, Moroccan government is currently facing serious problems in several regions of the country and it needs to address them efficiently without further delay. To solve these problems, the government needs to embark on several large-scale projects.

The Moroccan government must address the needs of the citizens who have been protesting in Al Hoceima and elsewhere in the country. It needs to acknowledge the need to listen to the oppressed and work seriously to improve their living conditions. A weak response to the demands of these protesters will surely precipitate additional problems.

A humanitarian decision

However, the state’s commitment to addressing internal problems cannot come at the expense of its foreign policy interests. Putting their emotions and hasty judgements on the issue aside, Moroccans should be proud of this symbolic, yet humanitarian, decision demonstrating Morocco’s political savoir-faire.

READ MORE: Morocco offers to mediate Qatar-GCC crisis

By announcing that it would be sending food supplies to Qatar, Morocco showed that it would not take part in an unwise dispute among the Gulf countries. Instead, it confronted the crisis with a well-reasoned and balanced approach calculated to reflect its leadership on the world stage.

Morocco's decision to play the card of neutrality in the Qatar-GCC rift is strategic and the country may soon take up a bigger role in this crisis by acting as a mediator.

By staying neutral and deciding not to follow countries’ that are blockading Qatar, Morocco is preserving the balanced relationship between King Mohammed VI and the other kings and princes of the Gulf.

In so doing, the country is preserving the independence of its foreign policy decisions, and proving that its moves in the international arena are not based on the agendas and stratagems of other countries. The decision is courageous as it distinguishes Morocco’s foreign policy from Saudi Arabia.

Morocco’s decision to send food aid to Qatar, which came only days after the king offered to mediate between the parties, demonstrates that the country has learned its lesson from its hasty 2009 decision to sever relations with Iran because of Bahrain.

Not only was Morocco’s decision to aid the people of Qatar politically wise, but it will likely be beneficial to Morocco, in the short, medium and long terms. Morocco is in urgent need of foreign investment to embark on necessary large-scale infrastructure projects. Qatar and its people will never forget Morocco’s symbolic humanitarian gesture in their time of need.

Strong relations with Saudi Arabia and the UAE

Morocco’s decision to send food to Qatar is unlikely to harm its relations with Saudi Arabia and the United Arab Emirates. Relations between Morocco’s king and the leaders of these two countries are currently too strong to be affected by a decision like this.

OPINION: Making sense of recent protests in Morocco

Saudi Arabia and the UAE’s strong relations with Algeria also influenced Morocco’s decision to continue its relations with Qatar. Algeria has been trying to destabilise Morocco and establish an independent state in the Western Sahara for over four decades. Yet King Mohammed VI has not asked the Gulf countries, particularly Saudi Arabia and the UAE, to sever their ties with Algeria. In fact, both countries are working towards strengthening their relations with Algeria and the UAE is among the largest foreign investors in Algeria.

Its renewed ties with Iran were also influential over Morocco’s decision to stay neutral in this crisis. Morocco restored its diplomatic relations with Iran last October, after more than six years of severed ties due to Iran’s conflict with Bahrain. The decision to renew ties came at the height of tensions between Saudi Arabia and Iran, because of Iran’s nuclear ambitions and the war in Syria. Despite this, Morocco’s decision to restore ties with Iran did not affect its relations with its Gulf allies.

Similarly, in Egypt, Morocco did not immediately recognise General Abdel Fattah el-Sisi’s presidency after the coup against Mohamed Morsi, although Saudi Arabia and the UAE did so. Since Sisi seized power, relations between Morocco and Egypt have not returned to the same level as before 2011 and remained tense. Yet, while relations between the two countries have not improved, this has not affected relations between Morocco and its Gulf allies.

In the past month, King Mohamed VI cancelled a trip to a summit in Riyadh and a visit to Egypt at the last moment and these decisions were neither arbitrary nor coincidental. It is far more likely that Morocco received intelligence that the outcome of the conference would not serve its interests. Therefore, by cancelling these visits, the King aimed to avoid being trapped in regional calculations of the Gulf states.

Morocco’s decision to play the card of neutrality in the Qatar-GCC rift is strategic and the country may soon take up a bigger role in this crisis by acting as a mediator.

Samir Bennis is a political analyst with more than eight years of experience as a political adviser with an Arab mission to the United Nations in New York. He is the co-founder of Morocco World News, and an expert on Morocco’s foreign policy, UN-related issues and the Maghreb.

The views expressed in this article are the author’s own and do not necessarily reflect Al Jazeera’s editorial policy.