diff --git a/CHANGELOG.md b/CHANGELOG.md
index bd6ede1..f56072d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,11 @@
 ## Development version
 
 
+Bug fixes:
+
+- Correctly handle geometries with Z dimension in ``to_crs()`` when using PyGEOS or
+  Shapely >= 2.0 (previously the z coordinates were lost) (#1345).
+
 ## Version 0.12.1 (October 29, 2022)
 
 Small bug-fix release removing the shapely<2 pin in the installation requirements.
diff --git a/geopandas/_vectorized.py b/geopandas/_vectorized.py
index 45d383d..b1700b4 100644
--- a/geopandas/_vectorized.py
+++ b/geopandas/_vectorized.py
@@ -1096,15 +1096,24 @@ def bounds(data):
 
 
 def transform(data, func):
-    if compat.USE_SHAPELY_20:
-        coords = shapely.get_coordinates(data)
-        new_coords = func(coords[:, 0], coords[:, 1])
-        result = shapely.set_coordinates(data.copy(), np.array(new_coords).T)
-        return result
-    if compat.USE_PYGEOS:
-        coords = pygeos.get_coordinates(data)
-        new_coords = func(coords[:, 0], coords[:, 1])
-        result = pygeos.set_coordinates(data.copy(), np.array(new_coords).T)
+    if compat.USE_SHAPELY_20 or compat.USE_PYGEOS:
+        if compat.USE_SHAPELY_20:
+            has_z = shapely.has_z(data)
+            from shapely import get_coordinates, set_coordinates
+        else:
+            has_z = pygeos.has_z(data)
+            from pygeos import get_coordinates, set_coordinates
+
+        result = np.empty_like(data)
+
+        coords = get_coordinates(data[~has_z], include_z=False)
+        new_coords_z = func(coords[:, 0], coords[:, 1])
+        result[~has_z] = set_coordinates(data[~has_z].copy(), np.array(new_coords_z).T)
+
+        coords_z = get_coordinates(data[has_z], include_z=True)
+        new_coords_z = func(coords_z[:, 0], coords_z[:, 1], coords_z[:, 2])
+        result[has_z] = set_coordinates(data[has_z].copy(), np.array(new_coords_z).T)
+
         return result
     else:
         from shapely.ops import transform

diff --git a/geopandas/tests/test_crs.py b/geopandas/tests/test_crs.py
index 1d9200a..b8983a6 100644
--- a/geopandas/tests/test_crs.py
+++ b/geopandas/tests/test_crs.py
@@ -58,6 +58,13 @@ def test_to_crs_transform__missing_data():
     assert_geodataframe_equal(df, utm, check_less_precise=True)
 
 
+def test_to_crs_transform__empty_data():
+    df = df_epsg26918().iloc[:0]
+    lonlat = df.to_crs(epsg=4326)
+    utm = lonlat.to_crs(epsg=26918)
+    assert_geodataframe_equal(df, utm, check_less_precise=True)
+
+
 def test_to_crs_inplace():
     df = df_epsg26918()
     lonlat = df.to_crs(epsg=4326)
@@ -77,6 +84,26 @@ def test_to_crs_geo_column_name():
     assert_geodataframe_equal(df, utm, check_less_precise=True)
 
 
+def test_to_crs_dimension_z():
+    # preserve z dimension
+    arr = points_from_xy([1, 2], [2, 3], [3, 4], crs=4326)
+    assert arr.has_z.all()
+    result = arr.to_crs(epsg=3857)
+    assert result.has_z.all()
+
+
+def test_to_crs_dimension_mixed():
+    s = GeoSeries([Point(1, 2), LineString([(1, 2, 3), (4, 5, 6)])], crs=2056)
+    result = s.to_crs(epsg=4326)
+    assert not result[0].is_empty
+    assert result.has_z.tolist() == [False, True]
+    roundtrip = result.to_crs(epsg=2056)
+    # TODO replace with assert_geoseries_equal once we expose tolerance keyword
+    # assert_geoseries_equal(roundtrip, s, check_less_precise=True)
+    for a, b in zip(roundtrip, s):
+        np.testing.assert_allclose(a.coords[:], b.coords[:], atol=0.01)
+
+
 # -----------------------------------------------------------------------------
 # Test different supported formats for CRS specification
 

Reprojection: loss of elevation when using pygeos 
With https://github.com/geopandas/geopandas/commit/5d1181af6bcca88351d84bb63fc0fbe0e32ce055 and pygeos support enabled, to_crs() transforms all geometries to 2-dimensions.

_vectorized.transform uses pygeos.get_coordinates, and the documentation mentions: Three-dimensional data is ignored.
geopandas/tests/test_crs.py::test_to_crs_dimension_z geopandas/tests/test_crs.py::test_to_crs_dimension_mixed
geopandas/tests/test_crs.py::test_to_crs_transform geopandas/tests/test_crs.py::test_to_crs_transform__missing_data geopandas/tests/test_crs.py::test_to_crs_transform__empty_data geopandas/tests/test_crs.py::test_to_crs_inplace geopandas/tests/test_crs.py::test_to_crs_geo_column_name geopandas/tests/test_crs.py::test_transform2[epsg_number-epsg_number] geopandas/tests/test_crs.py::test_transform2[epsg_number-epsg_string] geopandas/tests/test_crs.py::test_transform2[epsg_number-epsg_dict] geopandas/tests/test_crs.py::test_transform2[epsg_number-proj4_string] geopandas/tests/test_crs.py::test_transform2[epsg_number-proj4_dict] geopandas/tests/test_crs.py::test_transform2[epsg_string-epsg_number] geopandas/tests/test_crs.py::test_transform2[epsg_string-epsg_string] geopandas/tests/test_crs.py::test_transform2[epsg_string-epsg_dict] geopandas/tests/test_crs.py::test_transform2[epsg_string-proj4_string] geopandas/tests/test_crs.py::test_transform2[epsg_string-proj4_dict] geopandas/tests/test_crs.py::test_transform2[epsg_dict-epsg_number] geopandas/tests/test_crs.py::test_transform2[epsg_dict-epsg_string] geopandas/tests/test_crs.py::test_transform2[epsg_dict-epsg_dict] geopandas/tests/test_crs.py::test_transform2[epsg_dict-proj4_string] geopandas/tests/test_crs.py::test_transform2[epsg_dict-proj4_dict] geopandas/tests/test_crs.py::test_transform2[proj4_string-epsg_number] geopandas/tests/test_crs.py::test_transform2[proj4_string-epsg_string] geopandas/tests/test_crs.py::test_transform2[proj4_string-epsg_dict] geopandas/tests/test_crs.py::test_transform2[proj4_string-proj4_string] geopandas/tests/test_crs.py::test_transform2[proj4_string-proj4_dict] geopandas/tests/test_crs.py::test_transform2[proj4_dict-epsg_number] geopandas/tests/test_crs.py::test_transform2[proj4_dict-epsg_string] geopandas/tests/test_crs.py::test_transform2[proj4_dict-epsg_dict] geopandas/tests/test_crs.py::test_transform2[proj4_dict-proj4_string] geopandas/tests/test_crs.py::test_transform2[proj4_dict-proj4_dict] geopandas/tests/test_crs.py::test_crs_axis_order__always_xy geopandas/tests/test_crs.py::test_skip_exact_same geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_array geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_series geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_dataframe geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_dataframe_getitem_without_geometry_column geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_dataframe_setitem geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_dataframe_setitem_without_geometry_column geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_scalar[None] geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_scalar[scalar1] geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_scalar[scalar2] geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_crs_with_no_geom_fails geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_read_file geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_multiple_geoms geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_multiple_geoms_set_geom geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_assign_cols geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_copy geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_rename geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_geoseries_to_crs geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_array_to_crs geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_from_shapely geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_from_wkb geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_from_wkt geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_points_from_xy geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_original geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_ops geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_binary_ops geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_other geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_affinity_methods[affine_transform-arg0] geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_affinity_methods[translate-arg1] geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_affinity_methods[rotate-arg2] geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_affinity_methods[scale-arg3] geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_affinity_methods[skew-arg4] geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_slice geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_concat geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_merge geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_setitem_geometry geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_astype geopandas/tests/test_crs.py::TestGeometryArrayCRS::test_apply_geodataframe geopandas/tests/test_crs.py::TestSetCRS::test_set_crs[geoseries] geopandas/tests/test_crs.py::TestSetCRS::test_set_crs[geodataframe]