Siobhan McLaughlin, 46, was refused the benefit after her partner of 23 years John Adams died from cancer in January 2014 because the couple, who had four children, were not married or in a civil partnership.
But, by a majority of four justices to one, the Supreme Court ruled on Thursday that the current law on the allowance is “incompatible” with Human Rights legislation.
Giving the lead judgment, the court’s President Lady Hale said the couple’s children “should not suffer this disadvantage” because their parents chose not to marry.
Speaking after the ruling, Ms McLaughlin said: “For me, this case was always about the rights of bereaved children.
“I am so delighted that the Supreme Court shared our view that the law as it stands has discriminated against my children.
“I hope that my taking and succeeding with this challenge gives others both confidence and courage to continue to challenge the unfairness and inequalities in our laws in Northern Ireland and throughout the UK.”
Campaigners urged the Government to update the law to accommodate cohabiting couples who choose not to marry.
Alison Penny, director of the Childhood Bereavement Network, said the current rules affect an estimated 2,000 families a year.
She added: “We urge Parliament to amend the relevant legislation as quickly as possible, and to clarify the position for those parents who were previously deemed ineligible because of their marital status.
“We pay tribute to Siobhan for having the courage to bring this test case and improve the situation for thousands of grieving children and their surviving parents.”
Child Poverty Action Group’s director of policy Louisa McGeehan said: “The Government must now move swiftly to apply the principle and ensure that all children who experience the death of a parent are supported financially on the same basis as children whose parents are married.”
Ms McLaughlin, a special needs classroom assistant from Armoy, Co Antrim, was with Mr Adams, a groundsman, for 23 years and they had four children - Rebecca, 15, Billy, 16, Lisa, 21, and Stuart, 23.
Following Mr Adams’s death, Ms McLaughlin had to take on an evening job after being refused widowed parent’s allowance by the Northern Ireland Department for Communities.
Lady Hale said the purpose of the allowance was to “diminish the financial loss” caused to families with children by the death of a parent.
She added: “That loss is the same whether or not the parents are married or in a civil partnership with one another.”
But the judge said not every case where an unmarried parent is denied the allowance after the death of their partner will be unlawful.
The court also said it is up to the Government to decide whether or how to change the law.
A Department for Work and Pensions (DWP) spokesman said: “We will consider the court’s ruling carefully.
“Widowed parent’s allowance was a contributory benefit and it has always been the case that inheritable benefits derived from another person’s contributions should be based on the concept of legal marriage or civil partnership.
“This ruling doesn’t change the current eligibility rules for receiving bereavement benefits, which are paid only to people who are married or in a civil partnership.”