The passive voice in Spanish can be divided into two main types: the ser passive and the se passive.
The ser passive
The ser passive is mainly used in formal and written language and is constructed from the Spanish verb ser (to be) and participle of the main verb. It is somewhat similar to the passive construction in English:
El contrato fue firmado ayer.
The contract was signed yesterday.
Note that the verb ser is conjugated according to the head word, either singular or plural, and also according to the tense. However, the ser passive is not usually used in the present or imperfect tense. Additionally, the subject of the sentence is usually something known. The participle is inflected like an adjective, according to gender and number of the head word:
El producto fue fabricado en España.
The product was manufactured in Spain.
Las reglas han sido modificadas.
The rules have been modified.
If the agent is mentioned, it is expressed by adding the preposition por and the agent at the end of the sentence:
El proyecto ha sido aprobado por el director.
The project has been approved by the director.
More on the formation of the participle in chapter 3.6.
The se passive
The se passive is more common in Spanish. Se passive is not usually accompanied by an agent and it is very common in spoken but also in written language, as it is used a lot in advertisements and instructions, for example:
Se habla español en muchos países.
Spanish is spoken in many countries.
Se compra oro.
We buy gold.
Note that the verb adapts to the number of the object:
Se vende un coche usado.
A used car for sale.
Se venden coches usados.
Used cars for sale.
In spoken Spanish, the ellos and tú forms of verbs are also used impersonally to express the passive voice. In this case, they do not refer to a specific person but are used to speak about something in general, much like the “generic you” in English:
Cierran las tiendas a las seis.
The shops close at six.
Cuando vives en España, aprendes español rápidamente.
When you live in Spain, you learn Spanish quickly.