Construction will start by the end of the year and the factory will be ready to start production in 2026, VW said.
The Spanish government last week launched a bidding process to hand out around 3 billion euros ($3.3 billion) to promote EV production, with Volkswagen and its Spanish unit Seat among the bidders.
VW said it planned to spend more than 7 billion euros ($7.7 billion), along with external suppliers, on the Sagunto plant and to start EV production at Seat's factory outside Barcelona and at VW's factory outside Pamplona.
VW has embarked in an ambitious plan to build six large battery factories across Europe with an annual capacity of 240 GWh as it aims to become the world's leader in electric vehicles.
Sagunto will be the third of the battery cell gigafactories that VW plans to build in Europe by 2030.
The first is currently being built at Northvolt in northern Sweden, the second is in Salzgitter, Germany. The fourth factory will be built in eastern Europe. Skoda is promoting the Czech Republic as a location.
Automobilwoche contributed to this report