diff --git a/invenio_accounts/context_processors/jwt.py b/invenio_accounts/context_processors/jwt.py
index <HASH>..<HASH> 100644
--- a/invenio_accounts/context_processors/jwt.py
+++ b/invenio_accounts/context_processors/jwt.py
@@ -9,7 +9,7 @@
 """JWT context processors."""
 
 from flask import current_app, render_template
-from jinja2 import Markup
+from markupsafe import Markup
 
 from ..proxies import current_accounts
 
diff --git a/setup.py b/setup.py
index <HASH>..<HASH> 100644
--- a/setup.py
+++ b/setup.py
@@ -58,6 +58,7 @@ install_requires = [
     'Flask-Mail>=0.9.1',
     'Flask-Menu>=0.5.0',
     'Flask-Security-Invenio>=3.1.1',
+    'Jinja2>=3.1.0,<4.0.0',
     'invenio-base>=1.2.5',
     'invenio-celery>=1.2.3',
     'invenio-i18n>=1.3.1',
dependencies: fix markup removal from jinja2