As the future of power systems aims towards the implementation of microgrids, the need for their stable and secure operation increases. The key to secure microgrids’ operation, lies in proper optimisation. In this paper, the optimal unit commitment of an islanded hybrid microgrid is analysed. The proposed solution is based on a dynamic programming method, considering the weather conditions for distributed generator's operation, battery state of charge, and the backup generator. The presented case analyses a hybrid microgrid with a stochastic load. The test example reviews a microgrid that consists of a run-of-river power plant, wind, and photovoltaic generators.