diff --git a/config.h.in b/config.h.in
index 674f175..9a1571b 100644
--- a/config.h.in
+++ b/config.h.in
@@ -411,6 +411,9 @@
 /* Define if you include <X11/xpm.h> on a normal include path (be careful) */
 #undef XPM_INC_X11
 
+/* Set to 88 or 256 depending on Xterm color cube you want */
+#undef XTERM_COLORS
+
 /* Support Xterm style scrollbars */
 #undef XTERM_SCROLLBAR
 
diff --git a/configure.ac b/configure.ac
index 709b691..60e4a45 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,6 +106,7 @@ support_selectionscrolling=yes
 support_mousewheel=yes
 support_mouseslipwheel=yes
 support_text_blink=yes
+support_xterm_colors=88
 support_pointer_blank=yes
 support_scroll_rxvt=yes
 support_scroll_next=yes
@@ -148,6 +149,7 @@ AC_ARG_ENABLE(everything,
        support_mousewheel=no
        support_mouseslipwheel=no
        support_text_blink=no
+       support_xterm_colors=no
        support_pointer_blank=no
        support_scroll_rxvt=no
        support_scroll_next=no
@@ -177,6 +179,7 @@ AC_ARG_ENABLE(everything,
        support_mousewheel=yes
        support_mouseslipwheel=yes
        support_text_blink=yes
+       support_xterm_colors=88
        support_pointer_blank=yes
        support_scroll_rxvt=yes
        support_scroll_next=yes
@@ -397,6 +400,12 @@ AC_ARG_ENABLE(text-blink,
     support_text_blink=$enableval
   fi])
 
+AC_ARG_ENABLE(xterm-colors,
+  [  --enable-xterm-colors     enable Xterm 88 or 256 color model],
+  [if test x$enableval = x88 -o x$enableval = x256 -o x$enableval = xno; then
+    support_xterm_colors=$enableval
+  fi])
+
 AC_ARG_ENABLE(pointer-blank,
   [  --enable-pointer-blank  enable pointer blank when typing or inactive pointer],
   [if test x$enableval = xyes -o x$enableval = xno; then
@@ -827,6 +836,9 @@ fi
 if test x$support_text_blink = xyes; then
   AC_DEFINE(TEXT_BLINK, 1, Define if you want blinking text support)
 fi
+if test x$support_xterm_colors = x88 -o x$support_xterm_colors = x256; then
+  AC_DEFINE_UNQUOTED(XTERM_COLORS, $support_xterm_colors, Set to 88 or 256 depending on Xterm color cube you want)
+fi
 if test x$support_unicode3 = xyes; then
   AC_DEFINE(UNICODE_3, 1, Define if you want to represent unicode characters outside plane 0)
 fi
@@ -976,6 +988,9 @@ fi
 if test x$terminfo != x; then
   echo "  set TERMINFO to:            $terminfo"
 fi
+if test x$support_xterm_colors != xno; then
+  echo "  Xterm color cube:           $support_xterm_colors"
+fi
 echo "  default resource name:      $RESNAME"
 echo "  resource class:             $RESCLASS"
 if test x$RESFALLBACK != x; then
diff --git a/src/feature.h b/src/feature.h
index bc1ff5c..b2f5558 100644
--- a/src/feature.h
+++ b/src/feature.h
@@ -34,6 +34,8 @@
 # define XAPPLOADDIRLOCALE	X11LIBDIR "/%s/app-defaults"
 #endif
 
+#include "../config.h"
+
 /*-------------------------------SECURITY-------------------------------*/
 
 /*
@@ -85,7 +87,9 @@
 /*
  * Make colours match xterm colours instead of `traditional' rxvt colours
  */
-#define XTERM_COLORS
+#ifndef XTERM_COLORS
+#define XTERM_COLORS 256
+#endif
 
 /*
  * Disable separate colours for bold, underline and reverse video
diff --git a/src/init.C b/src/init.C
index a4109cf..1708cca 100644
--- a/src/init.C
+++ b/src/init.C
@@ -71,6 +71,7 @@ const char *const def_colorName[] =
     "rgb:00/ff/ff",             // 6/14: bright cyan    (Cyan)
     "rgb:ff/ff/ff",             // 7/15: bright white   (White)
 
+#if XTERM_COLORS == 88
     // 88 xterm colours
     "rgb:00/00/00",
     "rgb:00/00/8b",
@@ -144,6 +145,251 @@ const char *const def_colorName[] =
     "rgb:b9/b9/b9",
     "rgb:d0/d0/d0",
     "rgb:e7/e7/e7",
+#elif XTERM_COLORS == 256
+    // 256 xterm colours
+    "rgb:00/00/00",
+    "rgb:00/00/5f",
+    "rgb:00/00/87",
+    "rgb:00/00/af",
+    "rgb:00/00/d7",
+    "rgb:00/00/ff",
+    "rgb:00/5f/00",
+    "rgb:00/5f/5f",
+    "rgb:00/5f/87",
+    "rgb:00/5f/af",
+    "rgb:00/5f/d7",
+    "rgb:00/5f/ff",
+    "rgb:00/87/00",
+    "rgb:00/87/5f",
+    "rgb:00/87/87",
+    "rgb:00/87/af",
+    "rgb:00/87/d7",
+    "rgb:00/87/ff",
+    "rgb:00/af/00",
+    "rgb:00/af/5f",
+    "rgb:00/af/87",
+    "rgb:00/af/af",
+    "rgb:00/af/d7",
+    "rgb:00/af/ff",
+    "rgb:00/d7/00",
+    "rgb:00/d7/5f",
+    "rgb:00/d7/87",
+    "rgb:00/d7/af",
+    "rgb:00/d7/d7",
+    "rgb:00/d7/ff",
+    "rgb:00/ff/00",
+    "rgb:00/ff/5f",
+    "rgb:00/ff/87",
+    "rgb:00/ff/af",
+    "rgb:00/ff/d7",
+    "rgb:00/ff/ff",
+    "rgb:5f/00/00",
+    "rgb:5f/00/5f",
+    "rgb:5f/00/87",
+    "rgb:5f/00/af",
+    "rgb:5f/00/d7",
+    "rgb:5f/00/ff",
+    "rgb:5f/5f/00",
+    "rgb:5f/5f/5f",
+    "rgb:5f/5f/87",
+    "rgb:5f/5f/af",
+    "rgb:5f/5f/d7",
+    "rgb:5f/5f/ff",
+    "rgb:5f/87/00",
+    "rgb:5f/87/5f",
+    "rgb:5f/87/87",
+    "rgb:5f/87/af",
+    "rgb:5f/87/d7",
+    "rgb:5f/87/ff",
+    "rgb:5f/af/00",
+    "rgb:5f/af/5f",
+    "rgb:5f/af/87",
+    "rgb:5f/af/af",
+    "rgb:5f/af/d7",
+    "rgb:5f/af/ff",
+    "rgb:5f/d7/00",
+    "rgb:5f/d7/5f",
+    "rgb:5f/d7/87",
+    "rgb:5f/d7/af",
+    "rgb:5f/d7/d7",
+    "rgb:5f/d7/ff",
+    "rgb:5f/ff/00",
+    "rgb:5f/ff/5f",
+    "rgb:5f/ff/87",
+    "rgb:5f/ff/af",
+    "rgb:5f/ff/d7",
+    "rgb:5f/ff/ff",
+    "rgb:87/00/00",
+    "rgb:87/00/5f",
+    "rgb:87/00/87",
+    "rgb:87/00/af",
+    "rgb:87/00/d7",
+    "rgb:87/00/ff",
+    "rgb:87/5f/00",
+    "rgb:87/5f/5f",
+    "rgb:87/5f/87",
+    "rgb:87/5f/af",
+    "rgb:87/5f/d7",
+    "rgb:87/5f/ff",
+    "rgb:87/87/00",
+    "rgb:87/87/5f",
+    "rgb:87/87/87",
+    "rgb:87/87/af",
+    "rgb:87/87/d7",
+    "rgb:87/87/ff",
+    "rgb:87/af/00",
+    "rgb:87/af/5f",
+    "rgb:87/af/87",
+    "rgb:87/af/af",
+    "rgb:87/af/d7",
+    "rgb:87/af/ff",
+    "rgb:87/d7/00",
+    "rgb:87/d7/5f",
+    "rgb:87/d7/87",
+    "rgb:87/d7/af",
+    "rgb:87/d7/d7",
+    "rgb:87/d7/ff",
+    "rgb:87/ff/00",
+    "rgb:87/ff/5f",
+    "rgb:87/ff/87",
+    "rgb:87/ff/af",
+    "rgb:87/ff/d7",
+    "rgb:87/ff/ff",
+    "rgb:af/00/00",
+    "rgb:af/00/5f",
+    "rgb:af/00/87",
+    "rgb:af/00/af",
+    "rgb:af/00/d7",
+    "rgb:af/00/ff",
+    "rgb:af/5f/00",
+    "rgb:af/5f/5f",
+    "rgb:af/5f/87",
+    "rgb:af/5f/af",
+    "rgb:af/5f/d7",
+    "rgb:af/5f/ff",
+    "rgb:af/87/00",
+    "rgb:af/87/5f",
+    "rgb:af/87/87",
+    "rgb:af/87/af",
+    "rgb:af/87/d7",
+    "rgb:af/87/ff",
+    "rgb:af/af/00",
+    "rgb:af/af/5f",
+    "rgb:af/af/87",
+    "rgb:af/af/af",
+    "rgb:af/af/d7",
+    "rgb:af/af/ff",
+    "rgb:af/d7/00",
+    "rgb:af/d7/5f",
+    "rgb:af/d7/87",
+    "rgb:af/d7/af",
+    "rgb:af/d7/d7",
+    "rgb:af/d7/ff",
+    "rgb:af/ff/00",
+    "rgb:af/ff/5f",
+    "rgb:af/ff/87",
+    "rgb:af/ff/af",
+    "rgb:af/ff/d7",
+    "rgb:af/ff/ff",
+    "rgb:d7/00/00",
+    "rgb:d7/00/5f",
+    "rgb:d7/00/87",
+    "rgb:d7/00/af",
+    "rgb:d7/00/d7",
+    "rgb:d7/00/ff",
+    "rgb:d7/5f/00",
+    "rgb:d7/5f/5f",
+    "rgb:d7/5f/87",
+    "rgb:d7/5f/af",
+    "rgb:d7/5f/d7",
+    "rgb:d7/5f/ff",
+    "rgb:d7/87/00",
+    "rgb:d7/87/5f",
+    "rgb:d7/87/87",
+    "rgb:d7/87/af",
+    "rgb:d7/87/d7",
+    "rgb:d7/87/ff",
+    "rgb:d7/af/00",
+    "rgb:d7/af/5f",
+    "rgb:d7/af/87",
+    "rgb:d7/af/af",
+    "rgb:d7/af/d7",
+    "rgb:d7/af/ff",
+    "rgb:d7/d7/00",
+    "rgb:d7/d7/5f",
+    "rgb:d7/d7/87",
+    "rgb:d7/d7/af",
+    "rgb:d7/d7/d7",
+    "rgb:d7/d7/ff",
+    "rgb:d7/ff/00",
+    "rgb:d7/ff/5f",
+    "rgb:d7/ff/87",
+    "rgb:d7/ff/af",
+    "rgb:d7/ff/d7",
+    "rgb:d7/ff/ff",
+    "rgb:ff/00/00",
+    "rgb:ff/00/5f",
+    "rgb:ff/00/87",
+    "rgb:ff/00/af",
+    "rgb:ff/00/d7",
+    "rgb:ff/00/ff",
+    "rgb:ff/5f/00",
+    "rgb:ff/5f/5f",
+    "rgb:ff/5f/87",
+    "rgb:ff/5f/af",
+    "rgb:ff/5f/d7",
+    "rgb:ff/5f/ff",
+    "rgb:ff/87/00",
+    "rgb:ff/87/5f",
+    "rgb:ff/87/87",
+    "rgb:ff/87/af",
+    "rgb:ff/87/d7",
+    "rgb:ff/87/ff",
+    "rgb:ff/af/00",
+    "rgb:ff/af/5f",
+    "rgb:ff/af/87",
+    "rgb:ff/af/af",
+    "rgb:ff/af/d7",
+    "rgb:ff/af/ff",
+    "rgb:ff/d7/00",
+    "rgb:ff/d7/5f",
+    "rgb:ff/d7/87",
+    "rgb:ff/d7/af",
+    "rgb:ff/d7/d7",
+    "rgb:ff/d7/ff",
+    "rgb:ff/ff/00",
+    "rgb:ff/ff/5f",
+    "rgb:ff/ff/87",
+    "rgb:ff/ff/af",
+    "rgb:ff/ff/d7",
+    "rgb:ff/ff/ff",
+    "rgb:08/08/08",
+    "rgb:12/12/12",
+    "rgb:1c/1c/1c",
+    "rgb:26/26/26",
+    "rgb:30/30/30",
+    "rgb:3a/3a/3a",
+    "rgb:44/44/44",
+    "rgb:4e/4e/4e",
+    "rgb:58/58/58",
+    "rgb:62/62/62",
+    "rgb:6c/6c/6c",
+    "rgb:76/76/76",
+    "rgb:80/80/80",
+    "rgb:8a/8a/8a",
+    "rgb:94/94/94",
+    "rgb:9e/9e/9e",
+    "rgb:a8/a8/a8",
+    "rgb:b2/b2/b2",
+    "rgb:bc/bc/bc",
+    "rgb:c6/c6/c6",
+    "rgb:d0/d0/d0",
+    "rgb:da/da/da",
+    "rgb:e4/e4/e4",
+    "rgb:ee/ee/ee",
+#else
+#error XTERM_COLORS needs to be set to 88 or 256
+#endif
 
 #ifndef NO_CURSORCOLOR
     COLOR_CURSOR_BACKGROUND,
diff --git a/src/rxvt.h b/src/rxvt.h
index a57f947..cafeb84 100644
--- a/src/rxvt.h
+++ b/src/rxvt.h
@@ -549,7 +549,13 @@ enum colour_list {
   Color_White = maxCOLOR,
 #endif
   minTermCOLOR = Color_White + 1,
+#if !defined(XTERM_COLORS) || XTERM_COLORS == 88
   maxTermCOLOR = Color_White + 72,
+#elif (XTERM_COLORS == 256)
+  maxTermCOLOR = Color_White + 240,
+#else
+#error XTERM_COLORS needs to be set to 88 or 256
+#endif
 #ifndef NO_CURSORCOLOR
   Color_cursor,
   Color_cursor2,
-- 
1.5.2.rc0.56.g6169a


