diff --git a/_config.yml b/_config.yml
index 03a6c567eefaad2eb9b307285ec6faf167a57d50..f9e295a8f7b23cc6462a564e1298bebfdb7352cc 100644
--- a/_config.yml
+++ b/_config.yml
@@ -85,6 +85,8 @@ mermaid:
   version: "9.1.6"
   # Put any additional configuration, such as setting the theme, in _includes/mermaid_config.js
   # See also docs/ui-components/code
+  # To load mermaid from a local file use the `path` key to specify the location of the library instead; e.g.
+  # path: "/assets/js/mermaid.min.js"
 
 # Enable or disable heading anchors
 heading_anchors: true
diff --git a/_includes/head.html b/_includes/head.html
index 5a6c877704b97a95dbae47e2296a3a10e2d6bb09..9f38d0f4bc1c0b3d79357e2ee2456a75765c4bc5 100644
--- a/_includes/head.html
+++ b/_includes/head.html
@@ -23,13 +23,17 @@
   {% endif %}
 
   {% if site.mermaid %}
-    <script src="https://cdn.jsdelivr.net/npm/mermaid@{{ site.mermaid.version }}/dist/mermaid.min.js"></script>
+    {% if site.mermaid.path %}
+      <script src="{{ site.mermaid.path | relative_url }}"></script>
+    {% else %}
+      <script src="https://cdn.jsdelivr.net/npm/mermaid@{{ site.mermaid.version }}/dist/mermaid.min.js"></script>
+    {% endif %}
   {% endif %}
 
   <script src="{{ '/assets/js/just-the-docs.js' | relative_url }}"></script>
 
   <meta name="viewport" content="width=device-width, initial-scale=1">
-  
+
   {% for file in site.static_files %}
     {% if file.path == site.favicon_ico or file.path == '/favicon.ico' %}
       {% assign favicon = true %}
diff --git a/docs/configuration.md b/docs/configuration.md
index 5f799b856a3752a120762c24752772c12ead4492..74daea06727ccb677bf8ff2a304385830c0bd624 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -83,6 +83,8 @@ mermaid:
   version: "9.1.3"
 ```
 
+Provide a `path` instead of a `version` key to load the mermaid library from a local file.
+
 See [the Code documentation]({% link docs/ui-components/code.md %}#mermaid-diagram-code-blocks) for more configuration options and information.
 
 ## Aux links
diff --git a/docs/ui-components/code.md b/docs/ui-components/code.md
index 44d3efebc8a3ec28f4f66f470021ec4a724bf46b..ecd1a024b2bf56972560d1c0d1fe09c3f12c6d80 100644
--- a/docs/ui-components/code.md
+++ b/docs/ui-components/code.md
@@ -148,6 +148,16 @@ graph TD;
 
 *Note: for demonstration purposes, we've enabled mermaid on this site. It is still disabled by default, and users need to opt-in to use it.*
 
+### Using a local mermaid library
+
+In order to use a local version of the mermaid library instead of one provided by jsDelivr, you can specify a `path` key in the mermaid configuration instead of a `version` key.
+
+```yaml
+mermaid:
+  # To load mermaid from a local file use the `path` key to specify the location of the library instead; e.g.
+  path: "/assets/js/mermaid.min.js"
+```
+
 ## Copy button
 {: .d-inline-block }