diff --git a/lib/geocoder/lookups/bing.rb b/lib/geocoder/lookups/bing.rb
index 032942ef838e3ea643f64e329d831c2f517e64fc..ce78da803275e7cacd93976279a363ed557fc540 100644
--- a/lib/geocoder/lookups/bing.rb
+++ b/lib/geocoder/lookups/bing.rb
@@ -29,7 +29,7 @@ module Geocoder::Lookup
     end
 
     def sanitized_text(query)
-      URI.escape(query.sanitized_text) if !query.reverse_geocode?
+      URI.escape(query.sanitized_text.strip) if !query.reverse_geocode?
     end
 
     def results(query)
diff --git a/test/services_test.rb b/test/services_test.rb
index ba37b5f21412710fb9bbbff028d34b04089d9807..70e8109d56a2b9397e5b7ede4a92f49abcf60953 100644
--- a/test/services_test.rb
+++ b/test/services_test.rb
@@ -274,6 +274,16 @@ class ServicesTest < Test::Unit::TestCase
     assert_no_match /query/, url
   end
 
+  def test_bing_query_url_contains_address_with_trailing_and_leading_spaces
+    lookup = Geocoder::Lookup::Bing.new
+    url = lookup.query_url(Geocoder::Query.new(
+      " manchester, lancashire ",
+      :region => "uk"
+    ))
+    assert_match /Locations\/uk\/manchester,%20lancashire/, url
+    assert_no_match /query/, url
+  end
+
   # --- Nominatim ---
 
   def test_nominatim_result_components