Union and company negotiators reached a tentative agreement about 5 p.m. Tuesday, averting a strike that had been called to begin at midnight at the Northern Tier Refinery in St. Paul Park.

The deal, which must still be voted on by about 190 workers, came just in time, said Chris Riley, business agent for Teamsters Local 120. “We went to the edge of the cliff,” Riley said.

Union members voted overwhelmingly two weeks ago to authorize a strike when the labor contract expires. But, with the help of a federal mediator, the two sides reached a settlement.

Riley would not give details of the agreement, saying he wanted union members to see the proposal first. But he said leadership is recommending that the rank and file approve the deal. “It addresses safety issues, it addresses pay cuts,” he said of the tentative three-year contract.

The union, which represents refinery operators, maintenance workers and others, had said that management wanted to cut some workers’ pay, eliminate jobs and undermine seniority in a way that compromises safety. In 2006, the Teamsters struck the refinery for seven weeks, eventually reaching a settlement that included a 3.5 percent wage increase and a $1,500 ratification bonus. At the time, Marathon Oil Corp. owned the refinery, but it sold it and other assets in 2010 to two private equity funds.

They created Northern Tier Energy, a publicly traded master limited partnership based in Ridgefield, Conn. In November, the equity funds sold their interests to Western Refining, a publicly traded oil company based in El Paso, Texas. It now has a controlling stake in the Northern Tier Energy general partnership.

The company also has 163 company-operated and 74 franchise SuperAmerica stores in Minnesota and Wisconsin and owns a stake in a pipeline that delivers Canadian and North Dakota crude oil to Twin Cities refineries.

With recent upgrades, the St. Paul Park refinery can process 89,500 barrels of crude oil per day. It and Minnesota’s other, larger oil refinery, Flint Hills Resources in Rosemount, supply the bulk of the state’s motor fuel.