Open the door .. insert your key and rotate it through a full locking cycle. If it operates freely. Then more than likely your bolt is binding. Dont smother it with WD40... ( something tells me you have already done that) With the bolt stuck out of the side of the lock. Wipe a spot of vaseline on the bolt, making sure you get some under the bolt.
Then close the door and try it again. If it seems fo be eaier to lock. Then you will now know that the bolt was binding in the keep (thats the metal plate in the frame).
This problem is remedied by adjusting the hinges.
If when you open the door and turn the key through a full cycle... the lock sticks, then this tells you that the lock cylinder may be at fault.
Remove the cylinder, and put the key in and rotate it. If it rotates freely, then the problem may well be the locking mechanism..... and unless you can identify your locking mechanism ( there are hundreds and hundreds) it's time to call a locksmith.