After two days of marathon negotiations — and mounting frustration among coaches, players and fans — the NFL and the referees’ union announced at midnight Thursday that a tentative agreement had been reached to end a lockout that began in June.

The replacements worked the first three weeks of games, triggering a wave of outrage that threatened to disrupt the rest of the season. After a missed call cost the Green Bay Packers a win on a chaotic final play at Seattle on Monday night, the two sides really got serious.

“We are glad to be getting back on the field for this week’s games,” referees’ union president Scott Green said.

The tentative eight-year deal is the longest involving on-field officials in NFL history, and was reached with the assistance of two federal mediators. It must be ratified by 51 percent of the union’s 121 members, who plan to vote Friday and Saturday in Dallas.

The agreement hinged on working out salary, pension and retirement benefits for the officials, who are part-time employees of the league. Tentatively, it calls for their salaries to increase from an average of $149,000 a year in 2011 to $173,000 in 2013, rising to $205,000 by 2019.

Under the proposal, the current defined benefit pension plan will remain in place for current officials through the 2016 season or until the official earns 20 years’ service. The defined benefit plan will then be frozen.

Retirement benefits will be provided for new hires, and for all officials beginning in 2017, through a defined contribution arrangement. The annual league contribution made on behalf of each game official will begin with an average of more than $18,000 per official and increase to more than $23,000 per official in 2019.

Beginning with the 2013 season, the NFL will have the option to hire a number of officials on a full-time basis to work year round, including on the field. The NFL also will be able to retain additional officials for training and development, and can assign those officials to work games. The number of additional officials will be determined by the league.

“As you know, this has to be ratified and we know very little about it, but we’re excited to be back. And ready,” referee Ed Hochuli told The Associated Press in a telephone interview. “And I think that’s the most important message — that we’re ready.”

Replacement refs aren’t new to the NFL. They worked the first week of games in 2001 before a deal was reached. But those officials came from the highest level of college football; the current replacements do not. Their ability to call fast-moving NFL games drew mounting criticism through Week 3, climaxing last weekend when ESPN analyst Jon Gruden called their work “tragic and comical.”

The closest official to the play, at the back of the end zone, signaled for the clock to stop, while another official at the sideline ran in and then signaled touchdown.

The NFL said in a statement Tuesday that the touchdown pass should not have been overturned — but acknowledged Tate should have been called for offensive pass interference before the catch. The league also said there was no indisputable evidence to reverse the call made on the field.

That drew even louder howls of disbelief. Some coaches, including Miami’s Joe Philbin and Cincinnati’s Marvin Lewis, tried to restore some calm by instructing players not to speak publicly on the issue.

Fines against two coaches for incidents involving the replacements were handed out Wednesday.

“I accept the discipline and I apologize for the incident,” Belichick said.

Players were in no mood for apologies from anyone.

“I’ll probably get in trouble for this, but you have to have competent people,” Carolina receiver Steve Smith said. “And if you’re incompetent, get them out of there.”

Added Rams quarterback Sam Bradford: “I just don’t think it’s fair to the fans, I don’t think it’s fair to us as players to go out there and have to deal with that week in and week out. I really hope that they’re as close as they say they are.”

They were.

Rejoice, football fans! The NFL that we know and love is back! Offer your thoughts and comments in the section below…

(TM and Copyright 2012 CBS Radio Inc. and its relevant subsidiaries. CBS RADIO and EYE Logo TM and Copyright 2012 CBS Broadcasting Inc. Used under license. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed. The Associated Press contributed to this report.)