diff --git a/Cabal/src/Distribution/Simple/Configure.hs b/Cabal/src/Distribution/Simple/Configure.hs
index d8d2aecb80418efa3370007a7b3f7728a04b9a00..ac7bd852f0d458c687ea2e3637cf0817b33212d9 100644
--- a/Cabal/src/Distribution/Simple/Configure.hs
+++ b/Cabal/src/Distribution/Simple/Configure.hs
@@ -850,9 +850,9 @@ mkProgramDb cfg initialProgramDb = programDb
                  . userSpecifyPaths (configProgramPaths cfg)
                  . setProgramSearchPath searchpath
                  $ initialProgramDb
-    searchpath = getProgramSearchPath initialProgramDb
-                 ++ map ProgramSearchPathDir
+    searchpath = map ProgramSearchPathDir
                  (fromNubList $ configProgramPathExtra cfg)
+                 ++ getProgramSearchPath initialProgramDb
 
 -- -----------------------------------------------------------------------------
 -- Helper functions for configure
diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs
index 2f0d79c92849b171307b56f703f970bdb38a888d..978af213b1b1aa0ffd50f59339ec6c89aff6b903 100644
--- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs
+++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs
@@ -446,8 +446,8 @@ configureCompiler verbosity
         progdb   =
             userSpecifyPaths (Map.toList (getMapLast packageConfigProgramPaths))
           . modifyProgramSearchPath
-              (++ [ ProgramSearchPathDir dir
-                  | dir <- fromNubList packageConfigProgramPathExtra ])
+              ([ ProgramSearchPathDir dir
+               | dir <- fromNubList packageConfigProgramPathExtra ] ++)
           $ defaultProgramDb
 
 
diff --git a/cabal-testsuite/PackageTests/ExtraProgPath/MyLibrary.hs b/cabal-testsuite/PackageTests/ExtraProgPath/MyLibrary.hs
new file mode 100644
index 0000000000000000000000000000000000000000..a51c414bcd2afa90a815f67d4a723a287d9e2779
--- /dev/null
+++ b/cabal-testsuite/PackageTests/ExtraProgPath/MyLibrary.hs
@@ -0,0 +1 @@
+module MyLibrary () where
diff --git a/cabal-testsuite/PackageTests/ExtraProgPath/cabal.project b/cabal-testsuite/PackageTests/ExtraProgPath/cabal.project
new file mode 100644
index 0000000000000000000000000000000000000000..5a93e28e8782fe5dfd0fd6201cf4bcad03a07971
--- /dev/null
+++ b/cabal-testsuite/PackageTests/ExtraProgPath/cabal.project
@@ -0,0 +1 @@
+packages: *.cabal
\ No newline at end of file
diff --git a/cabal-testsuite/PackageTests/ExtraProgPath/my.cabal b/cabal-testsuite/PackageTests/ExtraProgPath/my.cabal
new file mode 100644
index 0000000000000000000000000000000000000000..2ddc23e47a9852d3530fa2e72de8818f814514fc
--- /dev/null
+++ b/cabal-testsuite/PackageTests/ExtraProgPath/my.cabal
@@ -0,0 +1,20 @@
+name: CheckExtraProgPath
+version: 0.1
+license: BSD3
+license-file: LICENSE
+author: Alexander Vershilov
+maintainer: Alexander Vershilov
+synopsis: Check Extra Prog Path
+category: PackageTests
+build-type: Simple
+cabal-version: 2.0
+
+description:
+    Check that Cabal recognizes an override of the prog path.
+
+Library
+    pkgconfig-depends: zlib
+    default-language: Haskell2010
+    build-depends: base <5.0
+    exposed-modules:
+        MyLibrary
diff --git a/cabal-testsuite/PackageTests/ExtraProgPath/pkg-config b/cabal-testsuite/PackageTests/ExtraProgPath/pkg-config
new file mode 100755
index 0000000000000000000000000000000000000000..7c5fafbf0cacc2a0aab1915e665cc78861c74f72
--- /dev/null
+++ b/cabal-testsuite/PackageTests/ExtraProgPath/pkg-config
@@ -0,0 +1,3 @@
+#!/usr/bin/sh
+
+exit 1;
diff --git a/cabal-testsuite/PackageTests/ExtraProgPath/setup.out b/cabal-testsuite/PackageTests/ExtraProgPath/setup.out
new file mode 100644
index 0000000000000000000000000000000000000000..b0edde0184f953cef8b980684861836204673077
--- /dev/null
+++ b/cabal-testsuite/PackageTests/ExtraProgPath/setup.out
@@ -0,0 +1,11 @@
+# cabal v2-build
+Warning: cannot determine version of <ROOT>/./pkg-config :
+""
+Warning: cannot determine version of <ROOT>/./pkg-config :
+""
+Resolving dependencies...
+Error: cabal: Could not resolve dependencies:
+[__0] next goal: CheckExtraProgPath (user goal)
+[__0] rejecting: CheckExtraProgPath-0.1 (conflict: pkg-config package zlib-any, not found in the pkg-config database)
+[__0] fail (backjumping, conflict set: CheckExtraProgPath)
+After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: CheckExtraProgPath (2)
diff --git a/cabal-testsuite/PackageTests/ExtraProgPath/setup.test.hs b/cabal-testsuite/PackageTests/ExtraProgPath/setup.test.hs
new file mode 100644
index 0000000000000000000000000000000000000000..80ee56f6287bf588b6e91a3bd4480ccefba74003
--- /dev/null
+++ b/cabal-testsuite/PackageTests/ExtraProgPath/setup.test.hs
@@ -0,0 +1,8 @@
+import Test.Cabal.Prelude
+
+-- Test that extra-prog-path overrides the path for pkg-config
+main = cabalTest $ do
+  -- skipped on windows because using a script to dummy up an executable doesn't work the same.
+  skipIfWindows
+  cdir <- testCurrentDir `fmap` getTestEnv
+  fails $ cabal "v2-build" ["--extra-prog-path="++cdir]
diff --git a/changelog.d/pr-8506 b/changelog.d/pr-8506
new file mode 100644
index 0000000000000000000000000000000000000000..445f2320e69c7d08a77641f91ebf2283539d608b
--- /dev/null
+++ b/changelog.d/pr-8506
@@ -0,0 +1,7 @@
+synopsis: prepend rather than append extra prog path
+packages: Cabal
+prs: #8506
+issues: #6304
+description: {
+    Prepends the extra-prog-path to the system path rather than appending, to allow binaries in the extra path to override defaults.
+}