The child, who cannot be named for legal reasons, was taken into foster care in Gloucestershire while on a supervised visit with its father.
The parents should have been given 14 days notice, and "serious errors" were made by the local authority, a family court ruled.
Gloucestershire County Council has apologised and said it had now updated its policies.
Judge Stephen Wildblood, in the family court in Gloucester, found the authority's actions were unlawful and had breached the family's human rights.
He said the authority did not pay sufficient regard to a care plan and a court's care order, it failed to comply with regulations, and no legal advice was sought before the child was taken into care last month.
The mother, who is in her early 20s, told the BBC it had been "incredibly traumatic and distressing" and that she hoped no other family had to suffer in the way that she and her child did
In a statement the council said it apologised "unreservedly".
"In our attempts to safeguard the welfare of this child, members of our children's social care team breached the terms of a previous court order.
"We also apologise to the child and the parents for our actions in this case and for any distress caused.
"This should never have happened and we have updated our policies and put in place safeguards, including ensuring that the assistant director or other senior officer will have oversight of all cases where action to remove children, who are subject to care orders, are being considered."
The child, who is aged under two years old, has since been returned to its mother.
A baby was removed from its vulnerable mother unlawfully, a judge has ruled.