Their wish came true Thursday after 1,800 tickets containing the winning number were sold in the tiny northern town of Granen near the Spain-France border.
Students at Madrid's Saint Ildefonso School picked and announced the winning number on national television.
Granen's winners split $940 million of the $3.29 billion lottery, dubbed "El Gordo," which means "The Fat One" in Spanish.
Residents spilled out onto the streets to dance, sing, give hugs and douse each other with sparkling wine.
The Gordo lottery aims for a share-the-wealth system, rather than a single jackpot, and thousands of numbers yield at least some kind of return. Lots of people chip in together and buy shares of several or many tickets, meaning it is common for multiple prizes to go to the same town.
Although Spain is struggling to come out of an almost two-year recession that has left the country with a eurozone-high 21.5 percent unemployment rate, El Gordo is ranked as the world's richest lottery.
Since it began in 1812, the Dec. 22 lottery has become a favorite holiday tradition. The country will hold another big lottery Jan. 6 to mark the Feast of the Epiphany. It is known as "El Nino" (The Child), in reference to the baby Jesus.
The Associated Press contributed to this report.