In many informal guides to Spanish pronunciation, it's usually stated that the Spanish sound represented by ñ is pronounced as a "ny" sequence in a similar way to the English ni in onion, companion etc. In fact, this is a little misleading*. As we'll see below, it turns out that:
On this page, we'll attempt to explain the difference, with some audio examples in Spanish.
* Note for Spanish speakers and/or phoneticians: we'll often refer informally to a "y" sound. We mean a palatal approximant, as represented by API [j] and occurring at the beginning of the English word yes. We do not mean a fricative; in words such as ya or leyendo, Spanish speakers tend to fricate the y sound (especially in careful speech in the second case), whereas this phenomenon does not generally occur in English.
In English onion etc— and also in a Spanish word such as genio— the tongue initially makes contact with a small part of the alveolar ridge (the ridge behind the teeth) for the "n" sound. Then, there's a relatively long glide into the following vowel (this is the "y" sound).
In contrast, in the Spanish ñ, the tongue initially makes a very "full" contact with the alveolar ridge, almost completely covering the area indicated by the solid red line in Figure 1. (In a [n] sound, the tongue makes contact with only a small portion of this area.) It also immediately covers part of the palate, indicated by the red dotted line. The tongue is then held steady in this position for about 50% longer than with [n]. Then, this steady state is followed by a more rapid glide than in the case of n + y,
To hear the difference between ño and nio, listen to the audio examples below, which are of a native speaker from Mexico City pronouncing the two phrases es un sueño (="it's a dream") and es un genio ("=he's a genious").
See Martínez Celdrán & Fernández Planas (2007), Manual de fonética española, pp. 124-134.
Spanish pronunciation index