diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc
index 0c25fae9626..781894985ee 100644
--- a/storage/innobase/fsp/fsp0fsp.cc
+++ b/storage/innobase/fsp/fsp0fsp.cc
@@ -1496,6 +1496,30 @@ fsp_free_page(
 			    mtr);
 		fsp_free_extent(space, offset, page_size, mtr);
 	}
+
+	if (space->purpose != FIL_TYPE_TEMPORARY) {
+		return;
+	}
+
+	ulint savept = mtr->get_savepoint();
+	if (buf_block_t* block = buf_page_get_gen(
+		    page_id_t(space->id, offset), univ_page_size,
+		    RW_X_LATCH, NULL, BUF_GET_IF_IN_POOL,
+		    __FILE__, __LINE__, mtr, NULL)) {
+		if (!block->page.oldest_modification) {
+			return;
+		}
+
+		buf_pool_t* buf_pool = buf_pool_from_block(block);
+		buf_pool_mutex_enter(buf_pool);
+		mutex_enter(&block->mutex);
+		/* The page cannot be flushed while we hold the x-latch. */
+		ut_ad(block->page.oldest_modification);
+		buf_flush_remove(&block->page);
+		buf_pool_mutex_exit(buf_pool);
+		mutex_exit(&block->mutex);
+		mtr->release_block_at_savepoint(savept, block);
+	}
 }
 
 /** Return an extent to the free list of a space.
