It's certainly advisable to use a yarn with the same gauge as called for in a pattern; however, you don't HAVE to! Keep in mind, though, that gauge affects not only the finished size of the garment, but it also affects how the knitted fabric drapes.
It's also important to realize that the gauges listed on yarn wrappers are estimates, and you really need to figure out what gauge YOU get with that particular yarn. But then, of course, you should be able to change your needle size to get the gauge for the pattern.
With that said, you are probably already familiar with the numbers assigned to many yarns (http://www.craftyarncouncil.com/weight.html). One reason these are included is to help people substitute different yarns than what's called for in a pattern.
So what it boils down to is this: Can you still get the pattern gauge with a heavier or lighter weight yarn? And does the fabric behave (drape) the way you want it to?
A yes answer to both of those means you can complete the pattern with a different size yarn using your regular measurements.
Now if your gauge is off (but the drape is okay), then you would have to adjust the pattern to get the right fit!