Education Minister John O'Dowd's decision to approve the amalgamation of two Co Fermanagh grammar schools was both irrational and unreasonable, the High Court has heard.
Proposals to close Collegiate Grammar and Portora Royal in Enniskillen, and merge them into one new school, are unlawful and should be quashed, a judge was told.
Legal action is being taken on behalf of a pupil at Collegiate in a bid to have the move halted.
Mr O'Dowd announced the closures last November, insisting his focus was on the needs of children rather than the institutions.
A petition against the plans, signed by 7,000 people, was handed in at Stormont in an effort to preserve the schools.
The battle to stop the merger, planned for September next year, has now moved to the courtroom.
Lawyers for the pupil seeking a judicial review claimed there was a failure to carry out a proper economic appraisal.
The impact on children having to operate on a split site also features in the case.
Barrister David Dunlop contended: "The relief being sought is that the court is invited ultimately to conclude the decision of the minister... to approve the development proposals was unlawful."
He claimed Mr O'Dowd got the decision wrong.
"Properly analysed in the context of the background, we say the minister's decision was irrational and, in fact, we go so far as to say in certain respects it was unreasonable," Mr Dunlop said.
"It was so unreasonable in the context that no authority could properly have reached it in the circumstances."
Founded in 1608 under a Royal Charter by James I, Portora's past pupils include playwrights Oscar Wilde and Samuel Beckett.
More recently singer songwriter Neil Hannon, who is frontman of The Divine Comedy, went to school there.
Collegiate Grammar traces its history back to 1916.
Under the proposals both schools would be discontinued and a new co-educational school with a 900-strong enrolment taking their place.
Mr Justice Colton was told the Collegiate pupil taking the legal action and all her friends are opposed to the closure.
"She does not think she would like to go to a mixed school," Mr Dunlop said.
Potential difficulties in travelling between locations to get to classes were also set out.
"She doesn't want to endure the upset and disruption of attending a new school at a split site," the barrister added.
The case continues.