diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index c6e6d3b2b86..961b8f05eef 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -19630,13 +19630,25 @@ getDependencies(Archive *fout)
 		 * Ordinarily, table rowtypes have implicit dependencies on their
 		 * tables.  However, for a composite type the implicit dependency goes
 		 * the other way in pg_depend; which is the right thing for DROP but
-		 * it doesn't produce the dependency ordering we need. So in that one
+		 * it doesn't produce the dependency ordering we need. So in that
 		 * case, we reverse the direction of the dependency.
+		 *
+		 * Similarly, the server's idea of the dependency direction for
+		 * partitioned indexes is backwards for our purposes, so reverse it.
+		 * This swap has no real effect during the object creation sequence,
+		 * because the leaf and partitioned indexes are not connected until we
+		 * issue INDEX ATTACH.  What it does for us is to ensure that when
+		 * --clean mode is used, the DROP INDEX commands come out in an order
+		 * that the server will accept.
 		 */
 		if (deptype == 'i' &&
 			dobj->objType == DO_TABLE &&
 			refdobj->objType == DO_TYPE)
 			addObjectDependency(refdobj, dobj->dumpId);
+		else if (deptype == 'P' &&
+				 dobj->objType == DO_INDEX &&
+				 refdobj->objType == DO_INDEX)
+			addObjectDependency(refdobj, dobj->dumpId);
 		else
 			/* normal case */
 			addObjectDependency(dobj, refdobj->dumpId);
