If two people speaking two dialects can understand each other, the two dialects are mutually intelligible. If two dialects are mutually intelligible, then they are the same language. If two dialects are mutually unintelligible, then they are different languages.
Dialect Continuum
Sometimes dialects form a dialect continuum. A situation where neighboring dialects are mutually intelligible, but distant dialects are not.