Index: wp-includes/class-wp-query.php
===================================================================
--- wp-includes/class-wp-query.php	(revision 40909)
+++ wp-includes/class-wp-query.php	(working copy)
@@ -2134,6 +2134,35 @@
 			$whichauthor .= " AND ({$wpdb->posts}.post_author = " . absint($q['author']) . ')';
 		}
 
+
+		// Comment query
+		if( isset( $q['comment_count'] ) ) {
+			if( is_numeric( $q['comment_count'] ) ) {
+				$q['comment_count'] = array(
+					'value'   => absint($q['comment_count']),
+				);
+			} // Falltrough to default array
+
+			if( isset( $q['comment_count']['value'] ) ) {
+				$q['comment_count'] = wp_parse_args($q['comment_count'], array(
+					'compare' => '=',
+				) );
+
+				$where .= " AND ( {$wpdb->posts}.comment_count ";
+
+				$compare_operators = array( '=', '!=', '>', '>=', '<', '<=' );
+				if ( in_array( $q['comment_count']['compare'], $compare_operators, true ) ) {
+					$where .= $q['comment_count']['compare'];
+				} else {
+					// Fallback to equal sign
+					$where .= "=";
+				}
+
+				// Now add the count
+				$where .= ' ' . absint( $q['comment_count']['value'] ) . ')';
+			}
+		}
+
 		// MIME-Type stuff for attachment browsing
 
 		if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] ) {
