diff --git a/bin/ruby-build b/bin/ruby-build
index 42361fcd..6e69d515 100755
--- a/bin/ruby-build
+++ b/bin/ruby-build
@@ -200,6 +200,7 @@ compute_md5() {
 verify_checksum() {
   # If there's no SHA2 support, return success
   [ -n "$HAS_SHA2_SUPPORT" ] || return 0
+  local checksum_command="compute_sha2"
 
   # If the specified filename doesn't exist, return success
   local filename="$1"
@@ -209,8 +210,14 @@ verify_checksum() {
   local expected_checksum=`echo "$2" | tr [A-Z] [a-z]`
   [ -n "$expected_checksum" ] || return 0
 
+  # If the checksum length is 32 chars, assume MD5, otherwise SHA2
+  if [ "${#expected_checksum}" -eq 32 ]; then
+    [ -n "$HAS_MD5_SUPPORT" ] || return 0
+    checksum_command="compute_md5"
+  fi
+
   # If the computed checksum is empty, return failure
-  local computed_checksum=`echo "$(compute_sha2 < "$filename")" | tr [A-Z] [a-z]`
+  local computed_checksum=`echo "$($checksum_command < "$filename")" | tr [A-Z] [a-z]`
   [ -n "$computed_checksum" ] || return 1
 
   if [ "$expected_checksum" != "$computed_checksum" ]; then
@@ -1007,6 +1014,12 @@ else
   unset RUBY_BUILD_MIRROR_URL
 fi
 
+if echo test | compute_md5 >/dev/null; then
+  HAS_MD5_SUPPORT=1
+else
+  unset HAS_MD5_SUPPORT
+fi
+
 SEED="$(date "+%Y%m%d%H%M%S").$$"
 LOG_PATH="${TMP}/ruby-build.${SEED}.log"
 RUBY_BIN="${PREFIX_PATH}/bin/ruby"
diff --git a/test/checksum.bats b/test/checksum.bats
index e89c2610..a8ec8976 100644
--- a/test/checksum.bats
+++ b/test/checksum.bats
@@ -57,6 +57,32 @@ export RUBY_BUILD_CACHE_PATH=
 }
 
 
+@test "package URL with valid md5 checksum" {
+  stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
+  stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
+
+  install_fixture definitions/with-md5-checksum
+  [ "$status" -eq 0 ]
+  [ -x "${INSTALL_ROOT}/bin/package" ]
+
+  unstub curl
+  unstub md5
+}
+
+
+@test "package URL with md5 checksum but no md5 support" {
+  stub md5 false
+  stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
+
+  install_fixture definitions/with-md5-checksum
+  [ "$status" -eq 0 ]
+  [ -x "${INSTALL_ROOT}/bin/package" ]
+
+  unstub curl
+  unstub md5
+}
+
+
 @test "package with invalid checksum" {
   stub shasum true "echo invalid"
   stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
diff --git a/test/fixtures/definitions/with-md5-checksum b/test/fixtures/definitions/with-md5-checksum
new file mode 100644
index 00000000..03fe65a2
--- /dev/null
+++ b/test/fixtures/definitions/with-md5-checksum
@@ -0,0 +1 @@
+install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#83e6d7725e20166024a1eb74cde80677" copy