The City of Vancouver has reached an agreement with Canadian Pacific Railway that will transform a contentious stretch of old rail corridor into a public greenway.

Under the deal, the city will pay $55 million to purchase the land on the railway route, which extends for nine kilometres from False Creek near Downtown Vancouver to Marpole on the city's south side.

The deal brings to an end a long-running dispute over the future of the unused rail corridor, which runs through pricey residential neighbourhoods on the west side of the city.

CP Rail has owned the land for more than a century, but it hasn't run trains on it for about 15 years. Vancouver had previously offered to buy the land, but the two sides could never agree on a price.

At one point, CP argued that the land was worth $400 million, a figure the city disputed. However, Robertson said both sides were determined to solve the dispute. An independent appraiser helped arrive at a price for the land that both sides felt was fair.

"I think both parties had a change of heart," the mayor told a news conference.

Greenway will draw tourists: mayor

Robertson described the agreement as a once-in-a-lifetime opportunity, saying the planned greenway — designed for cyclists and walkers — will enhance Vancouver's international reputation as a tourist destination.

"Thanks to this landmark agreement, the city will be able to transform the area into an outstanding greenway and connect neighbourhoods from False Creek to Marpole," Robertson told a news conference Monday.

The mayor was joined by Keith Creel, president and chief operating officer of CP Railway Ltd.

During the height of the dispute, CP warned residents it would use the vacant tracks for train traffic again, and tore down a number of community gardens.

A resident gestured helplessly after CP Rail cleared out community gardens in Feb. 2015 residents have spent years building. (Tina Lovgreen/CBC)

The mayor noted the route is still viewed as a transportation corridor which could, in the future, carry light passenger rail, alongside the greenway.

In the near future, the city will seek public input on the how the greenway will look. It's estimated the greenway will cost between between $25 and $35 million, Robertson said.