Home Affairs Minister Anders Ygeman told Swedish Radio News that the agreement means Morocco will take back young men found to be illegally living in Sweden.
"We agree that we should work together to bring about the return of Moroccan children and adolescents living in Sweden but that do not have the right to be here," Ygeman said after meeting Rachid Talbi Alami, the speaker of the Moroccan parliament.
Ygeman said Morocco was also prepared work jointly with Sweden to resolve issues of identification and repatriation.
About 800 young boys from Morocco and other North African countries are believed to be living Sweden.
The deal comes on the heels of Friday's announcement by the Swedish Foreign Ministry stating it would not recognize the disputed territory of Western Sahara as an independent nation. It also illustrates an about-face by the Moroccan government, which refused in the past to cooperate on helping the undocumented Moroccan youths here in Sweden.
Morocco has controlled about two-thirds of Western Sahara since 1975 and claims the stretch of desert, which has offshore fishing, phosphate reserves and oilfield potential, as its own.
Ygeman said he does not know if the government's decision on Western Sahara contributed to Morocco's U-turn on the issue but told Swedish Radio News that the "speaker was very careful to say that these two things were separate issues."
Regarding its decision not to recognize Western Sahara, the government said it was an issue best handled at the level of the United Nations.
"The matter of Western Sahara is a decolonisation issue at the UN and is on the Security Council agenda," Foreign Affairs Minister Margot Wallström said on Friday in statement. "The government supports the UN's efforts aimed at finding a fair, mutually acceptable, negotiated solution where the right of the Western Saharan people to self-determination is satisfied."