Uber Technologies Inc. has agreed to buy an on-demand electric-bike outfit that could help the ride-hailing company expand its service to customers traveling short distances.

The deal for Jump Bikes, recognizable by its bulky red bicycles with large baskets, gives Uber access to customers in Washington and San Francisco, where the startup ​has a few hundred bikes available to rent in increments of 30 minutes for $2. Uber, which isn’t releasing terms, expects the deal to close within the next few weeks.

Uber...