diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php
index 8b5f1f276c..f4ceeb879a 100644
--- a/src/wp-includes/class-wp-comment-query.php
+++ b/src/wp-includes/class-wp-comment-query.php
@@ -250,6 +250,8 @@ class WP_Comment_Query {
 	 *                                                      or space/comma-separated list of 'hold' (`comment_status=0`),
 	 *                                                      'approve' (`comment_status=1`), 'all', or a custom
 	 *                                                      comment status. Default 'all'.
+	 *     @type string[]          $status__not_in          Exclude comments from a given array of comment stati.
+	 *                                                      Default empty array.
 	 *     @type string|string[] $type                      Include comments of a given type, or array of types.
 	 *                                                      Accepts 'comment', 'pings' (includes 'pingback' and
 	 *                                                      'trackback'), or any custom type string. Default empty.
@@ -308,6 +310,7 @@ class WP_Comment_Query {
 			'post_status'               => '',
 			'post_type'                 => '',
 			'status'                    => 'all',
+			'status__not_in'            => array(),
 			'type'                      => '',
 			'type__in'                  => '',
 			'type__not_in'              => '',
@@ -570,6 +573,14 @@ class WP_Comment_Query {
 			$statuses = array( 'all' );
 		}
 
+		// unlink 'status', 'status__not_in' accepts only an array
+		$status__not_in = $this->query_vars['status__not_in'];
+		if ( ! is_array( $status__not_in ) ) {
+			$status__not_in = array();
+		}
+		$statuses = array_diff( $statuses, $status__not_in );
+		unset( $status__not_in );
+
 		// 'any' overrides other statuses.
 		if ( ! in_array( 'any', $statuses, true ) ) {
 			foreach ( $statuses as $status ) {
diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php
index 0fc0ff33d1..b5d69d01dd 100644
--- a/tests/phpunit/tests/comment/query.php
+++ b/tests/phpunit/tests/comment/query.php
@@ -5605,4 +5605,121 @@ class Tests_Comment_Query extends WP_UnitTestCase {
 		$this->assertSame( 1, $counts['all'] );
 		$this->assertSame( 1, $counts['total_comments'] );
 	}
+
+	/**
+	 * @ticket 41339
+	 * @covers WP_Comment_Query::get_comment_ids
+	 * @dataProvider data_status_not_in_excludes_not_any_status
+	 */
+	public function test_status_not_in_excludes_not_any_status( array $statuses, array $status__not_in, array $expected_statuses ) {
+		$post_id = self::factory()->post->create();
+
+		self::factory()->comment->create(
+			array(
+				'comment_post_ID'  => $post_id,
+				'comment_approved' => '1',
+			)
+		);
+		self::factory()->comment->create(
+			array(
+				'comment_post_ID'  => $post_id,
+				'comment_approved' => '0',
+			)
+		);
+		self::factory()->comment->create(
+			array(
+				'comment_post_ID'  => $post_id,
+				'comment_approved' => 'spam',
+			)
+		);
+
+		$query          = new WP_Comment_Query();
+		$found          = $query->query( array_merge( array( 'status' => $statuses ), array( 'status__not_in' => $status__not_in ) ) );
+		$found_statuses = array_map(
+			function ( $comment ) {
+				return $comment->comment_approved;
+			},
+			$found
+		);
+
+		$this->assertSameSets( $expected_statuses, $found_statuses, 'Expected comments statuses with status__not_in set failed.' );
+	}
+
+	/**
+	 * Data provider for testing status__not_in with statuses not any.
+	 * @ticket 41339
+	 */
+	public static function data_status_not_in_excludes_not_any_status(): array {
+		return array(
+			'status__not_in spam'    => array(
+				'statuses'          => array( 'approve', 'hold', 'spam' ),
+				'status__not_in'    => array( 'spam' ),
+				'expected_statuses' => array( '1', '0' ),
+			),
+			'status__not_in hide'    => array(
+				'statuses'          => array( 'approve', 'hold', 'spam' ),
+				'status__not_in'    => array( 'hold' ),
+				'expected_statuses' => array( '1', 'spam' ),
+			),
+			'status__not_in approve' => array(
+				'statuses'          => array( 'approve', 'hold', 'spam' ),
+				'status__not_in'    => array( 'approve' ),
+				'expected_statuses' => array( '0', 'spam' ),
+			),
+		);
+	}
+
+	/**
+	 * @ticket 41339
+	 * @covers WP_Comment_Query::get_comment_ids
+	 * @dataProvider data_status_any_ignores_status_not_in
+	 */
+	public function test_status_any_ignores_status_not_in( array $statuses, array $status__not_in, array $expected_statuses ) {
+		$post_id = self::factory()->post->create();
+
+		self::factory()->comment->create(
+			array(
+				'comment_post_ID'  => $post_id,
+				'comment_approved' => '1',
+			)
+		);
+		self::factory()->comment->create(
+			array(
+				'comment_post_ID'  => $post_id,
+				'comment_approved' => '0',
+			)
+		);
+
+		self::factory()->comment->create(
+			array(
+				'comment_post_ID'  => $post_id,
+				'comment_approved' => 'spam',
+			)
+		);
+
+		$query          = new WP_Comment_Query();
+		$found          = $query->query( array_merge( array( 'status' => $statuses ), array( 'status__not_in' => $status__not_in ) ) );
+		$found_statuses = array_map(
+			function ( $comment ) {
+				return $comment->comment_approved;
+			},
+			$found
+		);
+
+		$this->assertSameSets( $expected_statuses, $found_statuses, 'Comment statuses any must ignore status__not_in.' );
+	}
+
+	/**
+	 * Data provider for testing status__not_in with statuses any.
+	 * @ticket 41339
+	 */
+	public static function data_status_any_ignores_status_not_in(): array {
+		return array(
+			'status__not_in spam' => array(
+				'statuses'          => array( 'any' ),
+				'status__not_in'    => array( 'spam' ),
+				'expected_statuses' => array( '1', '0', 'spam' ),
+			),
+		);
+	}
 }
