Whenever I had battles with people at school, I would win because I simply just knew more about Pokemon than the other kids. I was the girl people asked "What moves are super effective against this type?" or "Should I use this move instead of this one?" so I felt like the knowledge I had gave me an edge over my classmates. When in doubt, or if you don't know something, there's never any shame in studying something so that you understand it.
Think about those small improvements you could make to your team, every little bit helps. Make sure your Pokemon are holding items, as a little bit of help is better than none at all. Is there a better move that you could be using instead of your current ones? Maybe making better use of a Pokemon's ability? There are a lot of small things you wouldn't think about at first, but if you put them all together they can be an immense help.
If your friend is using the same Pokemon every time, consider raising Pokemon in order to counter the ones he uses. Memorize the strategies he's using and find their weak spots. If you lose ten battles to figure out someone's strategy, it'll make up for it when you finally understand that strategy and can use it to beat him. Predicting your opponent successfully helps immensely in battles.
Sometimes the closest of battles can just be decided by luck, but playing your strategy to minimize how much you depend on luck can help a lot. It can also help to make your opponent rely more on luck, such as paralyzing them so they have to take a chance to be able to attack.
When all's said and done, battles are about having fun and losing to your friend like this can only help you get better, and you can get closer to beating him every time. I know these tips are really generalized, but I hope this helps! Good luck!
This is a really wholesome post and I love it, thank you for making it!