An adverse ruling could force Thailand back to the polls within months, ending a period of unusual political stability.