Police officers turned up at the boy's school in southern Sweden last year and told him to come with them, without informing him of the reason why, reports regional newspaper Helsingborgs Dagblad (HD).
Instead an officer phoned the boy's mother to tell her that her son was suspected of rape.
She was however able to immediately offer an alibi, knowing he had been at home at the time of the alleged incident, which was said to have taken place some 60 kilometres away.
When the officer called her by the wrong name she began to see what had gone wrong.
“It did not help that I pointed out my name wasn't what the police said it was. The officer only said that I had a son by that name. That is true, but I tried to explain that they must have seized the wrong person,” she told HD.
When she eventually managed to convince an officer to double check the boy's ID documents, it was discovered that although he had the same name as the suspect, a fellow pupil, his national personal identity number did not match.
By the time the boy was released, he had been locked up for two hours without being told why.
In a report submitted to a Parliamentary Ombudsman (Justitieombudsmannen) investigating the incident, police have now apologized about the teenager's ordeal.
The statement concludes that the boy should never have been brought in for questioning and that the officers collecting him from school failed to properly check the personal number on his ID documents.
The 17-year-old was awarded 1000 kronor ($117) in damages earlier this summer.