The UK Supreme Court has ruled the Scottish Government's Named Person scheme is "incompatible" with the European Convention of Human Rights.
The scheme was introduced through the Children's and Young People's Act passed by the Scottish Parliament in April 2013 and gained Royal Assent in 2014.
Despite the ruling the Scottish Government has vowed to make the necessary changes and remains "committed" to the scheme.
All children in Scotland from birth to their 18th birthday were due to be assigned a Named Person from August 31.
Justice of the Supreme Court Lord Hodge delivered the court's verdict.
He said: "We reach two conclusions: First, the information-sharing provisions of the 2014 Act are incompatible with the rights of children, young persons and parents under article eight of the European Convention on Human Rights.
"Secondly, this provisions may in practice result in disproportionate interference with those rights, with limited safeguards available to individuals affected. As presently drafted, they are at risk of placing those tasked with delivering the scheme on the ground in breach of importance regulations protecting privacy and confidentiality".
The Scottish Government, however, welcomed the ruling and vowed to alter the legislation to ensure the scheme can come into force in the future.
Education secretary John Swinney said: "I welcome the publication of today's judgment and the fact that the attempt to scrap the named person service has failed.
"The Supreme Court has stated that the aim of the legislation, in promoting and safeguarding the wellbeing of children and young people, is 'unquestionably legitimate and benign'. It makes clear that the principle of providing a named person to support children and families does not breach human rights.
"The court's ruling requires us to provide greater clarity about the basis on which health visitors, teachers and other professionals supporting families will share and receive information in their named person role. We will start work on this immediately so we can make the necessary legislative amendments. The service will be implemented nationally at the earliest possible date.
"Ministers remain absolutely committed to the named person policy, developed over several years in consultation with a wide range of individuals and organisations working across Scotland to support children and families. We will work closely with local authorities, health boards and other key public service partners to ensure that those performing the role have the support and guidance they need ahead of implementation."
Elaine Motion, the lawyer representing the campaign groups who brought the case to court, called the judgement "significant" and stated the ruling shows the Scottish Government "overstepped" human rights law.
Motion said: "This is a highly significant and extremely unusual judgment. Successful challenges to legislation are very rare.
"The action was brought as there was an important public interest issue with a real strength of feeling about the potential impact of the named persons scheme across Scottish society. That meant it was right to take the case all the way to the Supreme Court.
"The legal issues were undoubtedly very complex, but put simply, The Supreme Court has decided that the named person scheme, as it stands, breaches Article 8 of ECHR - and is therefore beyond the legal competency of the Scottish Government. In layman's terms, the Supreme Court has said that The Scottish Government has overstepped the line drawn by Article 8 to protect and respect private and family life.
She continued: "The Supreme Court has decided that the information sharing details of the named person scheme were not in accordance with law as they were lacking in the necessary precision to give protection against arbitrary interference. That was incompatible with Article 8.
"In addition, the court identified a central problem of the lack of required consent before sharing such information."
This is the second piece of legislation passed by the current Scottish Government which has been held up through the courts.
The Scottish Government's policy of the minimum pricing of units of alcohol has faced a lengthy legal battle from campaigners.