diff --git a/lib/spack/spack/modules/common.py b/lib/spack/spack/modules/common.py
index 1ed826a84495f4a58d8334ad4482c600956d98c5..6e0d062156b41e33c8fe638206329a8527fa817d 100644
--- a/lib/spack/spack/modules/common.py
+++ b/lib/spack/spack/modules/common.py
@@ -173,7 +173,7 @@ def merge_config_rules(configuration, spec):
         if constraint.endswith(':'):
             constraint = constraint.strip(':')
             override = True
-        if spec.satisfies(constraint):
+        if spec.satisfies(constraint, strict=True):
             if override:
                 spec_configuration = {}
             update_dictionary_extending_lists(spec_configuration, action)
diff --git a/lib/spack/spack/test/data/modules/tcl/autoload_with_constraints.yaml b/lib/spack/spack/test/data/modules/tcl/autoload_with_constraints.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..52796cad5beec8903a7a09da3ab203a6413c1b50
--- /dev/null
+++ b/lib/spack/spack/test/data/modules/tcl/autoload_with_constraints.yaml
@@ -0,0 +1,8 @@
+enable:
+  - tcl
+tcl:
+  ^mpich2:
+    autoload: 'direct'
+
+  ^python:
+    autoload: 'direct'
diff --git a/lib/spack/spack/test/modules/tcl.py b/lib/spack/spack/test/modules/tcl.py
index 9846b2048230daa83a775baa2171c80da91d41d3..b7b6a023cee373c3f631de10c2a0ceec21addc5a 100644
--- a/lib/spack/spack/test/modules/tcl.py
+++ b/lib/spack/spack/test/modules/tcl.py
@@ -276,3 +276,20 @@ def test_blacklist_implicits(
         for item in callpath_specs:
             writer = writer_cls(item)
             assert writer.conf.blacklisted
+
+    @pytest.mark.regression('9624')
+    @pytest.mark.db
+    def test_autoload_with_constraints(
+            self, modulefile_content, module_configuration, database
+    ):
+        """Tests the automatic loading of direct dependencies."""
+
+        module_configuration('autoload_with_constraints')
+
+        # Test the mpileaks that should have the autoloaded dependencies
+        content = modulefile_content('mpileaks ^mpich2')
+        assert len([x for x in content if 'is-loaded' in x]) == 2
+
+        # Test the mpileaks that should NOT have the autoloaded dependencies
+        content = modulefile_content('mpileaks ^mpich')
+        assert len([x for x in content if 'is-loaded' in x]) == 0