The federal government's school chaplaincy program has been ruled unlawful by the High Court.
Tony Abbott says he wants the school chaplaincy program to go on, despite the High Court ruling for a second time that federal funding for the scheme is unlawful.
Five High Court justices unanimously ruled on Thursday that laws designed to give a legal basis for the 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 High Court in a landmark decision in 2012 upheld his initial challenge against the program but the previous Labor government quickly passed fresh laws to keep it going.
But the court maintains the government still has no executive power to fund the program.
"The making of the payments was therefore held to be unlawful," the court said in a summary judgment.
But it answered the question of the law's validity narrowly, looking at it only in relation to the funding agreement with Scripture Union Queensland.
The ruling said wider questions of the legislation's construction and validity should not be considered in this case.
'We want it to continue': PM Abbott
The prime minister said the government was studying the judgment to ensure it understood the full effect, but he made it clear he did not want the program to come to an end.
"This is a policy that was invented by the coalition. It was supported by the coalition. It was confirmed by the coalition. So we very much support it and we want it to continue," Mr Abbott told reporters.
The court also ruled paying a chaplaincy provider to cover the salary of someone to work at a school didn't offer "benefits to students" as outlined in the constitution.
However, the judges said strengthening values and providing pastoral care for students was a desirable end.
'Fundamental defects in its argument'
The ruling is scathing of the Commonwealth, saying there were fundamental defects in its arguments about the scope of the executive's spending powers.
The judges also noted several of the Commonwealth's arguments in this case were the same as those rejected by the court in the first challenge.
"Their repetition does not demonstrate their validity," the court said.
The National School Chaplaincy Association said the court had left the way open for the federal government to direct money for chaplains via the states.
"We hope the federal government will again act swiftly to protect this vital and beneficial program for students," it said in a statement.
Australian Education Union president Angelo Gavrielatos wants the government to reconsider its support for the program and see how the money could be better used.