A method of controlling an ammonia production facility powered by a power network including one or more renewable power sources (72, 74), the ammonia production facility comprising a hydrogen production plant comprising at least one electrolyser (22a, 22b, 22n), a nitrogen production plant comprising an air separation unit, an ammonia production plant comprising an ammonia synthesis loop operable to process produced hydrogen and nitrogen to produce ammonia, a hydrogen storage resource and a nitrogen storage resource, the method being executed by at least one hardware processor, the method comprising: receiving time-dependent power data representative of one or more operational parameters of the power network; receiving (310, 320) time-dependent operational characteristic data representative of one or more operational parameters of the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource; defining one or more power constraints for the operational parameters of the power network; defining one or more process constraints for the operational parameters of the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource; generating (330, 340), using a model predictive control-based controller and based on the power data, the operational characteristic data, the one or more power constraints and the one or more process constraints, control set point values for the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource to achieve a pre-determined ammonia production rate for the ammonia production facility; and sending the control set point values to a control system to control the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource by adjusting one or more control set points of the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource to achieve the pre-determined ammonia production rate for the ammonia production facility. receiving time-dependent power data representative of one or more operational parameters of the power network; receiving (310, 320) time-dependent operational characteristic data representative of one or more operational parameters of the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource; defining one or more power constraints for the operational parameters of the power network; defining one or more process constraints for the operational parameters of the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource; generating (330, 340), using a model predictive control-based controller and based on the power data, the operational characteristic data, the one or more power constraints and the one or more process constraints, control set point values for the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource to achieve a pre-determined ammonia production rate for the ammonia production facility; and sending the control set point values to a control system to control the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource by adjusting one or more control set points of the hydrogen production plant, the nitrogen production plant, the ammonia production plant, the hydrogen storage resource and the nitrogen storage resource to achieve the pre-determined ammonia production rate for the ammonia production facility.