Mountain Lion: Not joining preferred WPA2 Wifi network

Well, now I can answer my question myself.

Go to Keychain Access and remove all airport passwords for this network from Login and System keychains.

Then create a new password in System. Enter the network password. Item Name and account name: name of the network. Click add. Then double click the new item in the list. Change kind to 'airport password'. Then click Access Control and select Allow all applications to access this item.

Restart your computer. If it doesn't join automatically join it manually, next startup it will work fine again.