A United Airlines passenger aircraft prepares to leave its gate and taxi to the runway at San Francisco International Airport in San Francisco, California.Robert Alexander | Getty ImagesThe newly elected leader of United Airlines pilots’ union has resigned after a series of his recent online posts sparked an outcry from some other aviators and union leaders. Neil Swindells, a Chicago-based Boeing 787 captain, was narrowly elected earlier this week to lead the union of more than 14,000 pilots. Some of the messages had surfaced before the leadership union’s vote, which he narrowly won. The election was held after the previous chairman resigned due to a family issue. Swindells, who could not immediately be reached for comment, announced his resignation in a note to pilots late Wednesday. United Airlines did not immediately comment. Swindells, as head of the pilot union, would have had a seat on United’s board of directors. The airline and the union are in the middle of contract negotiations and previous efforts to get to a deal have failed.On Sept. 16, two days after United announced a partnership with one-time rival Emirates at an event at Washington Dulles International Airport, Swindells wrote on a private message board for pilots: And I’m sure EMIRATES had NOTHING TO DO with the EMIRATES MALE CAPTAIN being flanked” by a United “FEMALE FIRST OFFICER.” He wrote that the event showed Emirates “DOMINANCE OF THE CODESHARE, while giving UNITED their desired DEI money shot!!!” Codesharing in the aviation industry is when partner airlines to market each other’s flights. Windells, who has been at United for nearly three decades, apologized “to anyone I have offended” on Tuesday for language “that was often colorful, heated, and inappropriate, but declined to step down at the time. In his resignation note to pilots Wednesday night, he said that “while many of these things have been taken completely out of context and publicly weaponized against me, I cannot ignore their existence and the damaging effect it has had on many of my fellow pilots.” Screenshots of some of Swindells posts were shared with CNBC. Hours before he stepped down, the head of the national Air Line Pilots Association issued a statement saying it would always “stand and fight” for an inclusive aviation community.”Under our democratic structure, United pilots elect their leaders and it’s up to them to decide who they want at the helm,” Capt. Joe DePete wrote.