A mechanic for American Airlines has been arrested and accused by federal authorities of tampering with the navigation equipment on a plane shortly before it was scheduled to depart with 150 passengers onboard. The Miami-to-Nassau flight was grounded just before takeoff in July, authorities said.

The mechanic, Abdul-Majeed Marouf Ahmed Alani of Tracy, Calif., was upset that contract negotiations between his union and the airline had stalled, and he wanted to delay the flight with the hopes that he would make overtime pay, federal prosecutors allege.

Alani was previously fired by Alaska Airlines for making maintenance mistakes, according to court documents that were first reported by Business Insider on Friday.

According to court documents, Alani, who joined American Airlines in 1988, also worked for Alaska Airlines from 1998 to 2008. He was fired from the airline following a maintenance mistake after working there for about 10 years, according to the discrimination lawsuit he filed against Alaska Airlines.

According to federal investigators, Alani, 60, inserted and glued a piece of foam into the air data module system on American Airlines Flight 2834 on July 17, preventing it from functioning normally. The system, which sits beneath the cockpit, is responsible for monitoring an aircraft’s speed, pitch and other flight data.

Crew members in the cockpit received an error message just as the Boeing 737-800 was approaching the runway and decided to abort the takeoff, authorities said.

“Alani stated that his intention was not to cause harm to the aircraft or its passengers,” said a criminal complaint affidavit filed in federal court in Miami. “Alani explained to law enforcement that he was upset at the stalled contract dispute between the union workers and American Airlines, and that this dispute had affected him financially. Alani claimed that he tampered with the target aircraft in order to cause a delay or have the flight canceled in anticipation of obtaining overtime work.”

Alani was taken into custody Thursday and is expected to appear in federal court in Miami on Friday. It is not immediately clear whether he has an attorney. He has been suspended from American Airlines, a company spokesman said.

Alani his lawsuit against Alaska Airlines in 2010, alleging that he was unfairly fired by his former employer as a result of discrimination based on his national origin. Alani is a U.S. citizen who was born in Baghdad. A court in California ruled in favor of Alaska Airlines, which said Alani made multiple maintenance mistakes during his time there.

“While it may be true that portions of the blame for the four events that preceded plaintiff’s termination may be attributable to other employees, plaintiff is the clear-cut common denominator in all of the incidents,” the judge noted at the time. “Serious mishaps clustered to plaintiff to an unusual extent.”

Alaska Airlines and American Airlines did not respond to immediate inquiries on Alani’s termination.

The TWU-IAM Association, Alani’s 12,000-member mechanics union, released a statement Thursday that did not explicitly mention Alani but condemned “any conduct by any individual that jeopardizes the safe operation of an aircraft.”

“Safety is the number one priority for our IAM and TWU members involved in the maintenance and operation of aircraft,” the union wrote. “These members are the most highly trained safety professionals in the airline industry.”

The union has been trying to secure a new contract with American Airlines for three years, the Associated Press reported. The company, which recently apologized to investors for various problems, has accused the union of purposefully slowing down work, causing hundreds of flights to be canceled over the summer.

Daily News Quiz: Another House Republican exits ahead of 2020

This June, American had a 4 percent flight-cancellation rate — the highest among U.S. carriers, and nearly seven times the cancellation rate of Delta.

“We’re behind,” the airline’s president, Robert Isom, said earlier this week. “We certainly haven’t produced the kind of margins and earnings that we had hoped. We haven’t run the best airline in our history.”

The airline said it would resume negotiations with the mechanics’ union on Sept. 16 with the help of a federal mediator, the AP wrote.

Following the July incident, the Boeing 737-800 was taken out of service and sent for maintenance, which was when the foam was discovered, the Miami Herald reported.

“American immediately notified federal law enforcement, who took over the investigation with our full cooperation,” an American Airlines spokesman, Ross Feinstein, said in an email.

“At American we have an unwavering commitment to the safety and security of our customers and team members, and we are taking this matter very seriously,” Feinstein wrote.

Passengers on Flight 2834 were put on a different plane, which then took them to Nassau, the airline said. The air data module system on the original plane has since been fixed, and the aircraft has been returned to service, he said.

Formal charges against Alani will be announced on Sept. 20 during his arraignment. According to federal prosecutors, he could face up to 20 years in jail, CBS reported.