The International Brotherhood of Teamsters and the federal government said Wednesday they had reached an agreement to end 25 years of strict oversight designed to root out corruption and alleged Mafia influence in the union’s highest ranks.

The proposed deal, which was reached with U.S. Attorney Preet Bharara’s office in Manhattan, would end a 1989 consent decree stemming from a landmark racketeering lawsuit brought a year earlier by the Justice Department. Prosecutors alleged that organized crime members had seized “an interest in and control of” the 1.3 million-member union.

The agreement calls for government oversight to be phased out over five years. Eventually, the union will appoint independent officers to probe corruption allegations, a task currently handled by a three-member independent review board that includes a government appointee.

The Teamsters also agreed to maintain an election process for top officers mandated by the consent decree in which all union members can vote. At many other unions, only convention delegates cast ballots.

Union officials said they expect a federal judge to approve the agreement at a Feb. 11 hearing.

Mr. Bharara said that while the Teamsters have made significant progress in ridding its ranks of corruption, the threat of wrongdoing by organized crime still exists and the government would continue to monitor the union’s handling of disciplinary matters.

“While threats persist, the organized crime influence the government found to have reached the highest echelons of IBT leadership in 1988 has long been expunged,” Mr. Bharara and the union wrote in a joint statement to the judge.

Teamsters President James P. Hoffa, who fought the consent decree for years, said it was a historic day for the union.

“After decades of hard work and millions of dollars spent, we can finally say that corrupt elements have been driven from the Teamsters and that the government oversight can come to an end,” Mr. Hoffa said.

Ken Paff, national organizer with a rank-and-file group called Teamsters for a Democratic Union and a Hoffa critic, praised the continuation of election rules.

He said a new requirement that the union pay for one mailing of campaign materials to all members before elections would help level the playing field for challengers to Mr. Hoffa.

“We’re pleased because we have protected and even enhanced the supervised right to vote for all members,” Mr. Paff said.

The Teamsters originally agreed to government oversight to settle the broad racketeering lawsuit. At the time, then-U.S. Attorney Rudolph Giuliani alleged the union had made a “devil’s pact” with the Mafia by allowing it to control officer elections.

The suit named as defendants 18 members of the union’s executive board and 26 alleged organized-crime members, 25 of whom had been convicted of crimes such as extortion, embezzlement and illegal union payoffs.

On Wednesday, Mr. Giuliani said he believed the consent decree had been a success, noting that oversight continued across Republican and Democratic administrations. He said he believed the union had cleaned up corruption, but noted that the Mafia is far weaker today.

“The Teamsters is now free to operate as a very legitimate union. There’s no burden placed on it to operate as a subsidiary of organized crime,” he said.

Before reaching the agreement under the Obama administration, union officials had lobbied unsuccessfully in the past for an end to the decree, including through negotiations with the Clinton administration.

The current deal was the result of years of settlement negotiations, the union and prosecutors said in their memorandum to the judge.

Last summer, the Teamsters asked a federal judge for the first time to end the consent decree.

At that time, prosecutors responded that they would support scaling back government control over the union but not eliminating the measures, saying that “corrupt and undemocratic practices persist at all levels of the union.”

A spokeswoman for the U.S. attorney’s office declined to comment Wednesday on the earlier statement.

The union wrote in a court filing last year that charges of corruption had dropped precipitously. Cases that involved alleged racketeering or other activity that prompted the consent decree fell to 33 in the past decade, from 144 in the first five years of the consent decree, the union wrote.