Julie Glassberg for The New York Times

Uber, the San Francisco start-up company, uses a clever algorithm to summon a car quickly with a smartphone app, but it had trouble outmaneuvering the politics of the City of Washington. After six months, the company has finally won a battle with the city, which had been trying to deem its service illegal.

The City Council of the District of Columbia on Tuesday afternoon passed a legislative amendment that formally legalized sedans like the ones that Uber’s car-service partners use. The bill will permit Uber to do business without regulation until the end of the year, when the legislation will need to be revisited.

That’s a sharp turn of events from Monday, when the City Council discussed a legislative amendment that would have fixed the prices of fares for sedans so that they would be five times the minimum cost of cabs. The author of that version of the amendment, Councilmember Mary Cheh, withdrew the legislation on Tuesday morning during a social media rally started by Travis Kalanick, Uber’s chief executive. He urged customers to sign a petition and send e-mails to council members to protest the amendment. The company’s customers sent thousands of e-mails. DCist, a news blog that covers the city, reported the news earlier.

Later on Tuesday, a new version of the bill was introduced by Councilmember Jack Evans and co-sponsored by three other members. This amendment allowed businesses like Uber to be exempt from regulation, and it did not include language about the minimum fare:

For the purposes of this subsection, a business that uses a mobile phone application to connect its users to sedan service shall be exempt from regulation by the commission, including the fares charged by the business, provided that: (1) an estimated fare is available to the user when the application is used to book a sedan; (2) the method for calculating the fare structure is provided by the business to the user of the mobile application prior to booking a sedan; (3) upon completion of the trip, the customer is provided a receipt that lists the pick-up point, drop-off point, and total fare paid; (4) the business providing the mobile application uses sedans that are licensed.

If passed, Ms. Cheh’s version of the amendment would have prevented Uber from eventually starting its new program, Uber X, which offers hybrid vehicles at a lower price, in Washington.

“We brought real thunder in 18 hours,” Mr. Kalanick said in an interview. “We gave a lot of constituents a voice, people who would never have been heard before.”

Uber’s fight with the district dates back to January, when the city conducted a sting operation that led to the ticketing of an Uber-using driver. Ron Linton, chairman of the city’s taxi commission, who led the sting, said Uber had broken rules by trying to be both a limousine service and a cab service.