diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index 6acb459..ce4da83 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -552,6 +552,9 @@ function wpautop( $pee, $br = true ) {
 	$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
 	$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
 
+	// If an opening or closing block element tag is preceded by an empty paragraph element, remove it.
+	$pee = preg_replace('!<p>\s*</p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
+
 	// If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
 	$pee = preg_replace('!<p>\s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
 
