Correction: An earlier version of this article incorrectly said that an Exxon Mobil pipeline spilled millions of gallons of oil into the Yellowstone River last year. Exxon Mobil put the amount spilled at 1,509 barrels (about 63,000 gallons). This version has been corrected.

Gov. Brian Schweitzer (D) says it took some doing to get Trans­
Canada to strike deals for an “on-ramp” that would allow companies drilling for oil in the Bakken reservoir in Montana and North Dakota to feed some of their output into the proposed 1,700-mile-long Keystone XL pipeline.

Every time TransCanada asked him about the slow pace of state permitting for the pipeline, Schweitzer said, he would ask them about their negotiations with Bakken producers. This went on, he said, for about 18 months.

“I had meetings with oil guys. Everyone was telling me about their problems with TransCanada,” Schweitzer recalled. “I said: ‘I’m a rancher. And when you got a horse, a 4- or 5-year-old coming along pretty good, and you come to a point where it locks up, and it weighs 1,200 or 1,300 pounds, and I weigh only 210. Then you just saddle it up, put a bridle on, tie a front leg to a saddle horn, and they’re standing there on three legs. Then you walk up and give them a push, and they just about fall down. When that happens, they listen.’ ”

The lesson for the oil producers was this, Schweitzer said with relish: “I said, ‘Tell you what I’ll do to TransCanada. I’ll tie one leg up there, and they’ll start listening.’ . . . That’s exactly what I did.”

Today TransCanada’s proposed Keystone XL, designed to carry petroleum from Alberta to Gulf Coast refineries in Texas, includes an on-ramp that could accommodate 100,000 barrels a day from the Bakken oil boom. The pipeline itself would not cross North Dakota, but it would have a regional link in Baker, Mont.

Indeed, as controversy exploded last year about whether the Obama administration should approve the line, Trans­Canada was able to make the case that the pipeline would help relieve the transportation bottleneck in Montana and North Dakota, where oil is being carried out of the area in trucks and rail cars.

“Today, TransCanada would say the smartest thing they ever did was sign those on-ramps,” Schweitzer said.

TransCanada chief executive Russ Girl­ing concedes that the company was initially cautious about adding an on-ramp. After all, in 2008, production from the Bakken basin was still revving up.

“We needed to understand the longevity of those resources,” Girling said.

Harold Hamm, chief executive of Continental Resources, which owns more drilling acreage than any other company in North Dakota, said that when he visited TransCanada executives four or five years ago, “I basically asked if they would haul oil from the Bakken. At that time, they weren’t interested in doing that. . . . They just cared about carrying the Canadian oil to the U.S. market. Period.”

Hamm said that after the Montana public utilities commission voted against letting TransCanada come through the state, the company’s position changed.

“Guess what,” Hamm said. “The next thing we know we’re having a meeting. TransCanada, producers. The governor was present, as was the governor of North Dakota. And TransCanada felt that an on-ramp seemed pretty feasible. It’s amazing how some of those things come about.”

“The spark was the governor,” Girling said of Schweitzer. “He said: ‘I can see growth and a pipeline coming through my back yard. You TransCanada and producers have to get together.’ He pushed it, and we’re all glad he did.”

The cost of putting an on-ramp in Montana — what TransCanada calls the Bakken Marketlink — will be about $140 million, TransCanada says, a small fraction of the pipeline’s estimated $7 billion cost. Girling said, “We found way to reconfigure our pipeline and in a short time sold all the space available.”

Now TransCanada is looking at other ways to expand its pipeline network in North Dakota and Montana.

Schweitzer, who calls himself the biggest Keystone XL supporter in the country, says that putting more Bakken formation oil in pipelines will reduce fuel use and greenhouse-gas emissions from trucks and trains. Pipelines carry just 56 percent of the oil out of the region, according to the governor’s office.

Not everyone in Montana is happy. Environmental groups are opposed to the pipeline, which in Montana would cross 220.6 miles of private land, 19.1 miles of state land and 42.6 miles of land managed by the Bureau of Land Management. There would be seven pump stations.

Many Montana pipeline foes also point to a spill a year ago in Montana’s Yellowstone River, where an Exxon Mobil pipeline that was not buried deep enough was damaged by trees and other things being carried downstream. The pipeline spilled more than 60,000 gallons of oil into the river.

Schweitzer said he has created a state pipeline safety board and uncovered half a dozen other pipelines, most installed 40 or 50 years ago, in danger of leaking into rivers.

He said pipeline construction has improved since those older ones. “Would you rather get in a wreck in a car built in 2012 or one built in 1960?” he said. “It’s the same in pipeline construction.”