Actor Samuel L. Jackson and former NBA star Magic Johnson have been mistaken for migrants "who encamped and used our money" in Italy after the pair were pictured while on holiday in the popular tourist destination Forte dei Marmi, a seaside town in Tuscany.

Johnson shared on social media pictures of himself and Jackson resting on a bench after a day of shopping on 16 August. The caption reads: "Sam & I chilling out on a bench yesterday in Forte dei Marmi, Italy. The fans started lining up to take pictures with us."

Shortly afterwards, comic actor Luca Bottura used one of the pictures to create a meme and, as local media reported, start a social experiment.

Bottura shared the picture along with the caption: "Boldrini's resources in Forte dei Marmi shop at Prada with our €35. Share this picture if you are outraged."

The caption refers to Laura Boldrini, President of the Chamber of Deputies of Italy, who has been criticised for her open policy on migration.

The politician has often claimed the peninsula needs more migrants, whom she defined as "resources" who can help the country's stagnant economy.

Many Italians have taken to social media to voice their dissent against migration and criticise the fact that – something dismissed several times as "fake news" – migrants receive €35 (£31; $41) per day from taxpayers' money.

Bottura's picture has been shared thousands of of times and attracted hundreds of comments on Facebook and Twitter. And while some people understood it was a way to make light of a controversial topic in the country, others expressed their "shame" and "disgust".

The Facebook post was shared by model Nina Moric, whose page has over 300,000 likes and recently said she is a sympathiser of the far-right party CasaPound Italy.

After her Facebook wall was flooded with thousands of comments, the model explained she had shared the post ironically and had worked with Johnson in the past. However, many people did not understand the irony, and posted comments expressing anti-immigration views, not realising who was in the image.

"Nina Moric is right and this is shameful ..I am not racist, but I know there are people who really do not have money, while these wear branded clothes and relax," wrote a Facebook user.

"Immigration is crushing us," said another one.

Some also insulted Moric, accusing her of being "stupid" for failing to realise the men in the picture were famous millionaires and a "hypocrite" as she is from Croatia, but lives in Italy.

She later wrote that her post was also a "social experiment", which showed people use social media to "confirm their prejudices, regardless of what the truth is. None of us are immune to this phenomenon. If you think migrants come here to [encamp] for €35 a day, that post will confirm it. If you think Nina Moric is a right-wing extremist, her post will confirm it."

Bottura later said on Facebook: "The meme has been shared thousands of times and 40% of people understood the provocation, 30% was outraged and 20% thought it was a racist meme and that I had failed to recognise Samuel Jackson and Earvin 'Magic' Johnson, (I will not reveal the 10%)."

Migration is a sensitive topic in Italy and has stirred heated debate in recent years as the country experiences a surge in the number of people who reach its coasts every year. It has been estimated that at least 600,000 migrants have reached Italy since 2014. Of these, more than 180,000 arrived in Italy via Libya in 2016.

In February, the UN-backed government in Libya and Italy reached an agreement to curb the number of people crossing the Mediterranean and combat people smuggling.

The Italian government also issued a Code of Conduct for NGOs, stipulating that rescue ships operated by humanitarian organisations cannot enter Libyan waters to pick up migrants and help them reach Italy.

In August, Italy sent a naval mission to help the Libyan coast guard prevent boats with migrants from reaching its shores. The ships were sent after the country approved a plan known as "Fortress Europe".