diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index df396bd..7ae5788 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -382,7 +382,7 @@ class GEOSGeometry(GEOSBase, ListMixin):
     @property
     def wkt(self):
         "Returns the WKT (Well-Known Text) representation of this Geometry."
-        return wkt_w().write(self).decode()
+        return wkt_w(self.hasz and 3 or 2).write(self).decode()
 
     @property
     def hex(self):
diff --git a/django/contrib/gis/geos/prototypes/io.py b/django/contrib/gis/geos/prototypes/io.py
index 1be7da8..1e80351 100644
--- a/django/contrib/gis/geos/prototypes/io.py
+++ b/django/contrib/gis/geos/prototypes/io.py
@@ -45,6 +45,18 @@ wkt_writer_write.argtypes = [WKT_WRITE_PTR, GEOM_PTR]
 wkt_writer_write.restype = geos_char_p
 wkt_writer_write.errcheck = check_string
 
+try:
+    wkt_writer_get_outdim = GEOSFunc('GEOSWKTWriter_getOutputDimension')
+    wkt_writer_get_outdim.argtypes = [WKT_WRITE_PTR]
+    wkt_writer_get_outdim.restype = c_int
+    wkt_writer_set_outdim = GEOSFunc('GEOSWKTWriter_setOutputDimension')
+    wkt_writer_set_outdim.argtypes = [WKT_WRITE_PTR, c_int]
+except AttributeError:
+    # GEOSWKTWriter_get/setOutputDimension has been introduced in GEOS 3.3.0
+    # Always return 2 if not available
+    wkt_writer_get_outdim = lambda ptr: 2
+    wkt_writer_set_outdim = lambda ptr, dim: None
+
 ### WKBReader routines ###
 wkb_reader_create = GEOSFunc('GEOSWKBReader_create')
 wkb_reader_create.restype = WKB_READ_PTR
@@ -151,6 +163,17 @@ class WKTWriter(IOBase):
         "Returns the WKT representation of the given geometry."
         return wkt_writer_write(self.ptr, geom.ptr)
 
+    @property
+    def outdim(self):
+        return wkt_writer_get_outdim(self.ptr)
+
+    @outdim.setter
+    def outdim(self, new_dim):
+        if not new_dim in (2, 3):
+            raise ValueError('WKT output dimension must be 2 or 3')
+        wkt_writer_set_outdim(self.ptr, new_dim)
+
+
 class WKBWriter(IOBase):
     _constructor = wkb_writer_create
     _destructor = wkb_writer_destroy
@@ -217,9 +240,10 @@ def wkt_r():
         thread_context.wkt_r = _WKTReader()
     return thread_context.wkt_r
 
-def wkt_w():
+def wkt_w(dim=2):
     if not thread_context.wkt_w:
         thread_context.wkt_w = WKTWriter()
+    thread_context.wkt_w.outdim = dim
     return thread_context.wkt_w
 
 def wkb_r():
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
index cbe5136..e18f809 100644
--- a/django/contrib/gis/geos/tests/test_geos.py
+++ b/django/contrib/gis/geos/tests/test_geos.py
@@ -80,7 +80,8 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
         "Testing WKT output."
         for g in self.geometries.wkt_out:
             geom = fromstr(g.wkt)
-            self.assertEqual(g.ewkt, geom.wkt)
+            if geom.hasz and geos_version_info()['version'] >= '3.3.0':
+                self.assertEqual(g.ewkt, geom.wkt)
 
     def test_hex(self):
         "Testing HEX output."
diff --git a/django/contrib/gis/tests/data/geometries.json.gz b/django/contrib/gis/tests/data/geometries.json.gz
index 683dc83..52a5430 100644
Binary files a/django/contrib/gis/tests/data/geometries.json.gz and b/django/contrib/gis/tests/data/geometries.json.gz differ
