Spanish groups nouns into noun classes using a property called "grammatical gender" (género in Spanish). (The word "gender" comes from the Latin word "genus": the original meaning of "gender" in English was "kind, sort, or genus".)
Spanish assigns most nouns to one of two grammatical classes: these classes are conventionally named masculine and feminine. A very small number of nouns have undecided gender: this means that currently there isn't universal agreement among native speakers regarding whether those words are grammatically masculine or feminine.
Most nouns for people and many nouns for animals specify the biological sex of the person or animal, and a different noun is used for a person or animal of the other sex. Many of these pairs of nouns differ only by the change of a suffix or the addition of a suffix (amig-o/amig-a, perr-o/perr-a, dios/dios-a, león/leon-esa, poet-a/poet-isa), but some pairs are completely different (hombre/mujer, caballo/yegua, toro/vaca). In most cases the noun for something that is perceived as biologically male is grammatically masculine and the noun for something that is perceived as biologically female is grammatically feminine.
For each masculine/feminine noun pair, historically one of the two nouns is the preferred noun for generic reference: that is, the plural form of that word refers to a mixed-sex group, while the singular form of that word refers to a single person or animal whose sex/gender is unknown or not identified. For most pairs the masculine word is used for generic reference; however, there are a few pairs for which the feminine word is used for generic reference.
Some nouns for people and animals have the same form for both grammatical genders (el/la artista, el/la dentista, el/la modista, el/la modelo).
Some nouns for people and animals are arbitrarily grammatically masculine or grammatically feminine regardless of the biological sex or social gender of the the person or animal (la persona, la víctima, el testigo, la rana, el sapo, la cabra, la ardilla). In the case of animals, if and when it is necessary to indicate the biological sex one usually uses one of the invariable adjectives "macho" (male) or "hembra" (female): la rana macho, las ardillas macho, el sapo hembra, los sapos hembra.
Nouns for things that do not have a biological sex (for example, table, water, peace, germs, physics) still have grammatical gender, and the gender is arbitrary.
Spanish also makes limited use of a third gender that is conventionally named neuter: however, no Spanish nouns have neuter gender. Rather, neuter gender is used to refer to concepts and statements for which there is no noun and no assignment of grammatical gender.
The grammatical gender of a noun affects all words that modify that noun: all articles and some adjectives have different masculine and feminine forms, and all articles and adjectives that modify a noun must have the same grammatical gender as the noun that they modify.
Gender-neutral personal address
In both English-speaking areas and Spanish-speaking areas there are social movements that advocate for changes with regard to how one refers to groups of people of different sexes and/or social genders, in how one refers to a person of unknown sex and/or social gender or to a person who identifies as a sex and/or social gender is neither female/feminine nor male/masculine, or in how one refers generically to a person of any sex and/or social gender. There is also social resistance to many of these proposed changes.
One popular solution in both languages is to favor using both masculine and feminine nouns and pronouns whenever sex/gender is unknown or whenever a group is mixed-gender: "he or she" rather than "he", or él o ella rather than él.
Another solution in English that is gaining popularity but is still controversial is using "singular they"; that is, using they, them, their, theirs and themself for third-person singular address for both generic reference or when referring to a person whose sex and/or social gender is neither male/masculine or female/feminine.
As there is not yet universal agreement in either English or Spanish regarding, most of the articles in this Grammar Spanish Reference that deal with grammatical gender describe customary usage.