Ryanair charges a €40 (£34) penalty to passengers who have forgotten to print their passes.
Judge Barbara Cordoba called the charges abusive and ruled airlines are responsible for providing boarding passes.
Ryanair said it will appeal against the decision. If the airline is unsuccessful in the European courts as well as the Spanish court it could be forced to scrap all its boarding pass charges.
Ryanair, in a statement, said: "Over 99.9% of Ryanair's passengers used our web check-in facility last year. 73 million passengers this year can't be wrong. Checking in online from the comfort of your home and avoiding airport queues is clearly what passengers want, and Ryanair will defend their interest by appealing this decision.
"Ryanair will appeal this decision. Ryanair will be pointing out during the appeal that all passengers agree at the time of booking that they will check in online and print off their boarding cards at least four hours prior to scheduled departure.
"It is remarkable that a Spanish judge could possibly suggest that this agreement between Ryanair and its passengers was breaking international law."
The case was brought by Dan Miró. The Spanish lawyer was forced to pay the €40 charge when he tried to board his flight at Girona airport, Spain, without a boarding pass in May 2010.
In November 2010 Ryanair created an ad featuring Prince William and Kate Middleton, who had a speech bubble above her head that proclaimed "Glad he's booking with Ryanair!!".