diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index e2096572c06cd341ef92df22d60f60ba643dbc53..2e642265df8474d38ed368282f3c46dede6b737f 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -3463,8 +3463,9 @@ $endif
       If the query results do not fit on the screen, they are piped
       through this command.  Typical values are
       <literal>more</literal> or <literal>less</literal>.  The default
-      is platform-dependent.  The use of the pager can be disabled by
-      using the <command>\pset</command> command.
+      is platform-dependent.  Use of the pager can be disabled by setting
+      <envar>PAGER</envar> to empty, or by using pager-related options of
+      the <command>\pset</command> command.
      </para>
     </listitem>
    </varlistentry>
diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c
index 655850bb2dcceb00fe0ffb1d0edd44de0d1bdef3..63514e342ebcca2761b3f6a6c38ddcbdc7d8b6c8 100644
--- a/src/bin/psql/print.c
+++ b/src/bin/psql/print.c
@@ -2208,6 +2208,12 @@ PageOutput(int lines, unsigned short int pager)
 			pagerprog = getenv("PAGER");
 			if (!pagerprog)
 				pagerprog = DEFAULT_PAGER;
+			else
+			{
+				/* if PAGER is empty or all-white-space, don't use pager */
+				if (strspn(pagerprog, " \t\r\n") == strlen(pagerprog))
+					return stdout;
+			}
 #ifndef WIN32
 			pqsignal(SIGPIPE, SIG_IGN);
 #endif
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index 770f23b1e2383b48d651ab5074a72ffded54e27a..2a85087ab6111392f49b61ea95a3fc1a8fd1317d 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -166,8 +166,9 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
 			screen_size.ws_col = 80;
 #endif
 			pagerenv = getenv("PAGER");
+			/* if PAGER is unset, empty or all-white-space, don't use pager */
 			if (pagerenv != NULL &&
-				pagerenv[0] != '\0' &&
+				strspn(pagerenv, " \t\r\n") != strlen(pagerenv) &&
 				!po->html3 &&
 				((po->expanded &&
 				  nTups * (nFields + 1) >= screen_size.ws_row) ||