diff --git a/pep2html.py b/pep2html.py
index 24b7c16fe2f..1a6443bdea9 100755
--- a/pep2html.py
+++ b/pep2html.py
@@ -438,8 +438,8 @@ def apply(self):
class PEPFooter(Transform):
"""Remove the References section if it is empty when rendered."""
- # Uses same priority as docutils.transforms.TargetNotes
- default_priority = 520
+ # Set low priority so ref targets aren't removed before they are needed
+ default_priority = 999
def apply(self):
pep_source_path = Path(self.document['source'])