diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index d09158c42..61f2c959a 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -1007,9 +1007,14 @@ inlineToHtml opts inline = do
       ishtml <- isRawHtml f
       if ishtml
          then return $ preEscapedString str
-         else do
-           report $ InlineNotRendered inline
-           return mempty
+         else if (f == Format "latex" || f == Format "tex") &&
+                "\\begin" `isPrefixOf` str &&
+                allowsMathEnvironments (writerHTMLMathMethod opts) &&
+                isMathEnvironment str
+                then inlineToHtml opts $ Math DisplayMath str
+                else do
+                  report $ InlineNotRendered inline
+                  return mempty
     (Link attr txt (s,_)) | "mailto:" `isPrefixOf` s -> do
                         linkText <- inlineListToHtml opts txt
                         obfuscateLink opts attr linkText s
diff --git a/test/command/3816.md b/test/command/3816.md
new file mode 100644
index 000000000..dba37bfec
--- /dev/null
+++ b/test/command/3816.md
@@ -0,0 +1,29 @@
+```
+% pandoc --mathjax -t html5
+This is an equation:
+\begin{equation}
+y+2 = 3
+\end{equation}
+
+This is a system of equations:
+\begin{align*}
+x^2+y^2 & = 2 \\
+\sin(y) & = 0.5
+\end{align*}
+
+This is Euler's formula:
+\begin{eqnarray*}
+e^{i\pi} + 1 & = & 0.
+\end{eqnarray*}
+^D
+<p>This is an equation: <span class="math display">\[\begin{equation}
+y+2 = 3
+\end{equation}\]</span></p>
+<p>This is a system of equations: <span class="math display">\[\begin{align*}
+x^2+y^2 &amp; = 2 \\
+\sin(y) &amp; = 0.5
+\end{align*}\]</span></p>
+<p>This is Euler’s formula: <span class="math display">\[\begin{eqnarray*}
+e^{i\pi} + 1 &amp; = &amp; 0.
+\end{eqnarray*}\]</span></p>
+```