marimarthe, try the following:
- If you have a computer as well, sign into the webpage www.icloud.com and open the Photos.app there. You can see, which photos are in iCloud.
- Now disable iCloud Photo Library on your iPhone in Settings > [your name] > iCloud > Photos, or go to Settings > Photos & Camera. It may take a very long time, until the iPhone will confirm, that iCloud Photo Library has been disabled.
- No you can delete photos from the iPhone, and they will stay in iCloud.
- Once you have freed enough storage, enable iCloud Photo Library again, also "Optimize Storage".