In law, a legal opinion is in certain jurisdictions a written explanation by a judge or group of judges that accompanies an order or ruling in a case, laying out the rationale and legal principles for the ruling.