Cannot resize APFS container even though there is a free space directly after it - diskutil error: -69743

Apparently a partition map needed repairing. It is worth noting, that this worked, while running First Aid from Disk Utility didn't help.

sudo diskutil repairdisk disk0

It warned about possibly destroying an EFI partition, so I backed up its contents:

Repairing the partition map might erase disk0s1, proceed? (y/N) y
Started partition map repair on disk0
Checking prerequisites
Checking the partition list
Adjusting partition map to fit whole disk as required
Checking for an EFI system partition
Checking the EFI system partition's size
Checking the EFI system partition's file system
Checking the EFI system partition's folder content
Checking all HFS data partition loader spaces
Checking booter partitions
Reviewing boot support loaders
Checking Core Storage Physical Volume partitions
The partition map appears to be OK
Finished partition map repair on disk0

... but the EFI partition survived, and then the resize worked:

diskutil apfs resizeContainer disk0s2 0