diff --git a/admin/settings/security.php b/admin/settings/security.php
index d0a7f9115d9..d869af55d2c 100644
--- a/admin/settings/security.php
+++ b/admin/settings/security.php
@@ -83,6 +83,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$temp->add(new admin_setting_configcheckbox('cookiesecure', get_string('cookiesecure', 'admin'), get_string('configcookiesecure', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('cookiehttponly', get_string('cookiehttponly', 'admin'), get_string('configcookiehttponly', 'admin'), 0));
$temp->add(new admin_setting_configtext('excludeoldflashclients', get_string('excludeoldflashclients', 'admin'), get_string('configexcludeoldflashclients', 'admin'), '10.0.12', PARAM_TEXT));
+ $temp->add(new admin_setting_configcheckbox('loginpasswordautocomplete', get_string('loginpasswordautocomplete', 'admin'), get_string('loginpasswordautocomplete_help', 'admin'), 0));
$ADMIN->add('security', $temp);
diff --git a/blocks/login/block_login.php b/blocks/login/block_login.php
index 81c6b3df491..09559727cae 100644
--- a/blocks/login/block_login.php
+++ b/blocks/login/block_login.php
@@ -48,7 +48,12 @@ class block_login extends block_base {
$this->content->text .= '';
$this->content->text .= '
';
- $this->content->text .= '
';
+
+ if (!empty($CFG->loginpasswordautocomplete)) {
+ $this->content->text .= '';
+ } else {
+ $this->content->text .= '';
+ }
$this->content->text .= '';
diff --git a/lang/en/admin.php b/lang/en/admin.php
index 26c31a12c9b..64eba60c45a 100644
--- a/lang/en/admin.php
+++ b/lang/en/admin.php
@@ -675,6 +675,8 @@ $string['log'] = 'Logs';
$string['logguests'] = 'Log guest access';
$string['logguests_help'] = 'This setting enables logging of actions by guest account and not logged in users. High profile sites may want to disable this logging for performance reasons. It is recommended to keep this setting enabled on production sites.';
$string['loginhttps'] = 'Use HTTPS for logins';
+$string['loginpasswordautocomplete'] = 'Prevent password autocompletion on login form.';
+$string['loginpasswordautocomplete_help'] = 'Having this off will let users save their account password in their browser. Switching this setting on will result in your site no longer following XHTML strict validation rules.';
$string['loglifetime'] = 'Keep logs for';
$string['longtimewarning'] = 'Please note that this process can take a long time.';
$string['mail'] = 'Email';
diff --git a/login/index_form.html b/login/index_form.html
index cd9f8a4bc5d..137ab1261d0 100644
--- a/login/index_form.html
+++ b/login/index_form.html
@@ -40,7 +40,7 @@ if ($show_instructions) {