Unlocking can be done in a few ways and it depends entirely on the situations encountered:
Network Unlock: This procedure requires a number that can be obtained from the carrier where you've purchased the phone or from a local service shop. You can do it for a small fee in both ways. However, if the phone is under contract, it might cost you much more (carrier only!).
Phone unlock: If your phone has been locked because of PIN or Pattern, then input a wrong PIN or Password until it asks for Gmail recovery. Input the address and wait for a code. An Internet connection is requred for this process. Or you can unlock it using Factory Reset, but it will wipe all your apps and settings. Use Volume Up & Volume Down + Power button until the Recovery menu appears. Select Wipe Data and then reboot.
Volume buttons: Navigate
Power button: OK/Confirm.