Yes, sleep affects weight loss and vice versa.
It is true that some insomniacs do lose weight. But those are usually the same people who lose weight when they are unhappy, and they are mostly thin anyway, right?
People who are overweight often gain if they cannot sleep, because their reaction to the problem of insomnia, just like any other problem, is to try to cure it with food.
Some diets advise you not to eat within 2 hours of going to sleep. This is fine for many people, but sometimes this means we go to bed hungry. This often stops us sleeping.
Then either we get up and grab a snack (usually the fastest thing, not the healthiest). Or we lie there all night, hungry and unable to sleep. The next day we are tired and in a bad mood. Result: more likely to cheat.
If this is your problem, then it can be a good idea to plan a snack before going to bed each night. Write this into your food plan for the day, then you don't need to cheat.
It's also important to get enough exercise earlier in the day. Don't exercise right before you sleep, but concentrate on relaxing activities such as yoga or meditation at that time.
Taking a bath often helps too. The warmth of the water relaxes the whole body and prepares us for sleep.
Long term insomnia requires a more thorough approach. If you find that you cannot sleep for many nights in a row, or you are constantly tired, waking early or having disturbed sleep, then you can benefit from a thorough program to improve your sleep.
You may find that if you tackle the insomnia, your eating patterns will automatically improve and you will lose weight without even trying.