diff --git a/core/core.services.yml b/core/core.services.yml
index c56c778..164b612 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -1026,7 +1026,7 @@ services:
     arguments: ['@csrf_token']
   maintenance_mode:
     class: Drupal\Core\Site\MaintenanceMode
-    arguments: ['@state', '@current_user']
+    arguments: ['@settings', '@state', '@current_user']
   maintenance_mode_subscriber:
     class: Drupal\Core\EventSubscriber\MaintenanceModeSubscriber
     arguments: ['@maintenance_mode', '@config.factory', '@string_translation', '@url_generator', '@current_user', '@bare_html_page_renderer']
diff --git a/core/lib/Drupal/Core/Site/MaintenanceMode.php b/core/lib/Drupal/Core/Site/MaintenanceMode.php
index cac817c..ddc07f9 100644
--- a/core/lib/Drupal/Core/Site/MaintenanceMode.php
+++ b/core/lib/Drupal/Core/Site/MaintenanceMode.php
@@ -24,12 +24,22 @@ class MaintenanceMode implements MaintenanceModeInterface {
   protected $state;
 
   /**
+   * The settings.
+   *
+   * @var \Drupal\Core\Site\Settings
+   */
+  protected $settings;
+
+  /**
    * Constructs a new maintenance mode service.
    *
+   * @param \Drupal\Core\Site\Settings $settings
+   *   The settings.
    * @param \Drupal\Core\State\StateInterface $state
    *   The state.
    */
-  public function __construct(StateInterface $state) {
+  public function __construct(Settings $settings, StateInterface $state) {
+    $this->settings = $settings;
     $this->state = $state;
   }
 
@@ -37,6 +47,11 @@ public function __construct(StateInterface $state) {
    * {@inheritdoc}
    */
   public function applies(RouteMatchInterface $route_match) {
+    $maintenance_mode_settings = $this->settings->get('system.maintenance_mode', NULL);
+    if ($maintenance_mode_settings !== NULL) {
+      return $maintenance_mode_settings;
+    }
+
     if (!$this->state->get('system.maintenance_mode')) {
       return FALSE;
     }
diff --git a/core/modules/system/src/Form/SiteMaintenanceModeForm.php b/core/modules/system/src/Form/SiteMaintenanceModeForm.php
index 6370497..d583dd0 100644
--- a/core/modules/system/src/Form/SiteMaintenanceModeForm.php
+++ b/core/modules/system/src/Form/SiteMaintenanceModeForm.php
@@ -9,6 +9,7 @@
 
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Site\Settings;
 use Drupal\Core\State\StateInterface;
 use Drupal\Core\Form\ConfigFormBase;
 use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -66,11 +67,18 @@ protected function getEditableConfigNames() {
    */
   public function buildForm(array $form, FormStateInterface $form_state) {
     $config = $this->config('system.maintenance');
+
+    $settings = Settings::get('system.maintenance_mode');
+    if ($settings !== NULL) {
+      drupal_set_message(t('The "system.maintenance_mode" setting is set in the settings.php, so it is not possible to change it here.'));
+    }
+
     $form['maintenance_mode'] = array(
       '#type' => 'checkbox',
       '#title' => t('Put site into maintenance mode'),
       '#default_value' => $this->state->get('system.maintenance_mode'),
       '#description' => t('Visitors will only see the maintenance mode message. Only users with the "Access site in maintenance mode" <a href=":permissions-url">permission</a> will be able to access the site. Authorized users can log in directly via the <a href=":user-login">user login</a> page.', array(':permissions-url' => $this->url('user.admin_permissions'), ':user-login' => $this->url('user.login'))),
+      '#disabled' => $settings !== NULL,
     );
     $form['maintenance_mode_message'] = array(
       '#type' => 'textarea',
diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php
index ad557f5..7050230 100644
--- a/sites/default/default.settings.php
+++ b/sites/default/default.settings.php
@@ -642,6 +642,13 @@
 # $settings['container_base_class'] = '\Drupal\Core\DependencyInjection\Container';
 
 /**
+ * Configure whether the maintenance mode is enabled/disabled.
+ *
+ * As long this value is set, the UI won't allow you to set it.
+ */
+# $settings['system.maintenance_mode'] = TRUE;
+
+/**
  * Trusted host configuration.
  *
  * Drupal core can use the Symfony trusted host mechanism to prevent HTTP Host
