diff --git a/CHANGELOG.ja.rdoc b/CHANGELOG.ja.rdoc
index 370eea2ab9e..eb6fb976c51 100644
--- a/CHANGELOG.ja.rdoc
+++ b/CHANGELOG.ja.rdoc
@@ -14,6 +14,7 @@
 * (JRuby) Clear the XPath cache on attr removal. (#1109)
 * `XML::Comment.new` argument types are now consistent and safe (and documented) across MRI and JRuby. (#1224)
 * (MRI) Restoring support for Ruby 1.9.2 that was broken in v1.6.4.1 and v1.6.5. (#1207)
+* Check if `zlib` is available before building `libxml2`. (#1188)
 
 
 ==== 互換性
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index 73e250465b0..c5944b40259 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -18,6 +18,7 @@
 * (JRuby) Clear the XPath cache on attr removal. (#1109)
 * `XML::Comment.new` argument types are now consistent and safe (and documented) across MRI and JRuby. (#1224)
 * (MRI) Restoring support for Ruby 1.9.2 that was broken in v1.6.4.1 and v1.6.5. (#1207)
+* Check if `zlib` is available before building `libxml2`. (#1188)
 
 
 ==== Compatibility Note
diff --git a/ext/nokogiri/extconf.rb b/ext/nokogiri/extconf.rb
index bf4efcf1d93..63bd205c585 100644
--- a/ext/nokogiri/extconf.rb
+++ b/ext/nokogiri/extconf.rb
@@ -461,6 +461,12 @@ def install
     end
   end
 
+  unless windows_p
+    preserving_globals {
+      have_library('z', 'gzdopen', 'zlib.h')
+    } or abort 'zlib is missing; necessary for building libxml2'
+  end
+
   libxml2_recipe = process_recipe("libxml2", dependencies["libxml2"], static_p, cross_build_p) do |recipe|
     recipe.files = ["ftp://ftp.xmlsoft.org/libxml2/#{recipe.name}-#{recipe.version}.tar.gz"]
     recipe.configure_options += [