Prime Minister Tony Abbott has vowed to shore up the school chaplaincy program after the High Court found federal funding to be invalid.

The national school chaplaincy program will continue despite the High Court ruling its federal funding is unlawful.

Five High Court justices unanimously ruled on Thursday that laws designed to give a legal basis for the chaplaincy funding were invalid.

The challenge to the program was the second brought by Queensland father Ron Williams, who believes there is no place in secular public schools for religious programs.

The court in 2012 upheld his initial challenge but the previous Labor government passed laws to keep the program going.

However, the court found on Thursday the government had no executive power to fund the agreement with Scripture Union Queensland.

“The making of the payments was therefore held to be unlawful,” the court said.

Prime Minister Tony Abbott said the government would consider the impact of the judgment, but a way would be found to continue funding chaplains.

“This is a policy that was invented by the coalition, so we very much support it and we want it to continue,” he said.

Labor also went to the 2013 election pledging funding for the chaplaincy program but broadened it to cover secular student welfare officers.

Opposition finance spokesman Tony Burke said the government should ensure the services continue.

The opposition also fears the judgment could impact on rural, industry development, environmental and health programs and some veterans payments.

“Labor is prepared to offer bipartisan support on this issue to ensure the continuity of commonwealth government programs,” Mr Burke said.

Attorney-General George Brandis rejected concerns the judgment would make other programs invalid.

He said the government was now considering how to continue the program, consistent with the Constitution and the High Court’s ruling.

“The basis upon which the High Court struck it down does leave other options,” he told ABC television.

The court decision means the more than $150 million in program payments become debts owed to the Commonwealth. Finance Minister Mathias Cormann has decided to take no recovery action.

Greens senator Penny Wright said the money should be channelled into school mental health programs, a sentiment backed by the Australian Education Union.

“The time for amateurs is over – there is a mental health crisis in our schools,” she said, urging greater spending on counsellors, psychologists and welfare workers.

The National School Chaplaincy Association said the federal government could now direct money for chaplains via the states.

Liberal MP Andrew Laming, who convinced former prime minister John Howard to start the program eight years ago, said it had broad support.

He took a swipe at what he called the “loose alliance of Greens, gays and atheists” who mounted a continuous campaign against chaplaincy.

“You are clearly out of touch,” Mr Laming said.