I managed to resolve it as follows:
I went into the secret Hardware test menu (Settings -> My device -> All specs -> tap 4 or 5 time on Kernel version)
Then I selected the proximity sensor (#9) and selected Calibrate. It failed once, but on a second retry (going back to the menu and back to the...