The remains of the infant, thought to be up to six weeks old, were found wrapped in a blanket on an old railway path in the Seafield area of Edinburgh in July 2013.
His mother or family have never been traced, and his identity remains a mystery.
He was laid to rest following a funeral service at Seafield Cemetery.
The service was arranged by Police Scotland and members of the public were invited to attend.
Leading the service, Reverend Erica Wishart, of Tranent Parish Church, told mourners: "This is the kind of tragedy that surely touches everyone who hears about it. All of us who gather here today are grieving.
"We represent everyone in this community and beyond who feels deep sadness that this tiny baby is never going to have the chance to grow up and live his life."
The minister said those gathered may feel "anger and shock" at what had happened, or perhaps a whole range of emotions.
"We are here to say goodbye to this wee one, with the dignity and respect he deserves. We are here to mourn the life that could have been. And we are here to affirm that every life is precious in God's eyes," she said.
"This baby boy may not have been given a name - we may not know where he came from or who gave birth to him - but the Bible tells us that God knew him even before he was born and his whole being - body, soul and spirit - is engraved on the palm of God's hand."
A number of mourners were visibly tearful as the boy's tiny white coffin was lowered into the ground and as a lone piper played.
More than 200 people have turned out for the funeral of an unidentified baby boy found dead on a path two years ago.