* Nigerian election came close to unravelling

* Plotters wanted to abduct election commissioner

* Aide alerted election monitors via text message

* Disruption could have ignited widespread violence

By Ed Cropley and Tim Cocks

ABUJA, April 16 (Reuters) - As Muhammadu Buhari closed in on Nigeria's presidency, an aide to election commission chairman Attahiru Jega sent a text message to an independent voting monitor, warning of an imminent threat to the electoral process.

The aide had unearthed a plot by supporters of President Goodluck Jonathan to disrupt the public announcement of the national election results and kidnap Jega in a bid to wreck the count, according to pro-democracy advocates and a Nigeria-based diplomat.

Central to the plan, they said, were Jega's security detail and Godsday Orubebe, a former cabinet minister from Jonathan's Niger Delta, an area whose leaders feared a change of power would mean an end to the perks it enjoyed under Jonathan's presidency.

Orubebe's role was to cause a disturbance at the headquarters of the commission as cover for the abduction of Jega. Orubebe did not respond to requests for comment on the details of the plot.

The commission, called INEC, also declined to comment and turned down requests for an interview with Jega, whom Reuters was unable to reach independently. Reuters found no evidence to suggest that Jonathan, who conceded defeat in the election, was involved. His spokesman and his party, the PDP, did not respond to requests for comment.

While the plot would likely not have changed the result, it could have unleashed fury among Buhari supporters in the north, where 800 people were killed in rioting after his last election defeat in 2011.

But the plot's failure enabled Africa's most populous country to complete its first credible vote since independence in 1960.

"NIGERIA ON TRIAL"

The plot to derail the election in its closing moments was pieced together by Reuters from the text message, events on the ground and interviews with democracy advocates and diplomats in the capital, Abuja.

When he sent the SMS, the election official, whom the sources declined to name for his own protection, hoped the outside world would hear of the plot, the text of the message made clear.

"Fellow countrymen, Nigeria on Trial," read the SMS sent on the morning of March 31 to Clement Nwankwo, head of the Situation Room, an Abuja-based coalition of human rights groups and democracy advocates monitoring the polls. Reuters later saw the SMS.

"Plans are on storm the podium at the ICC Collation Centre and disrupt the process," it continued, the official dropping words and letters in his haste.

"Nobody is sue what will happen. Please share this as widely as possible."

At that moment, INEC chairman Jega was about to preside over the announcement of results.

TALLY COUNT

Since the end of army rule in 1999, all four previous votes had been marred by violence and ballot-rigging.

The 2015 poll was different in two crucial aspects.

It was a genuine race, pitting Jonathan, saddled with an ailing economy and an Islamist insurgency, against a former general promising to get tough on corruption and the Boko Haram insurgents.

Voters had also been given biometric ID cards linked to their photographs and fingerprints, making it hard to inflate voter numbers significantly.

As tallies from around the country showed Buhari on course for a win, unidentified PDP hard-liners started to panic, seeking ways of manipulating the count, Nwankwo and the diplomat said, citing political contacts in the Delta and Abuja.

Realising they could not engineer an outright win, PDP agents set about doctoring the tally at collation centres in pro-Jonathan areas to ensure Buhari failed to meet a requirement for 25 percent support in two thirds of states, Nwankwo said, citing reports from election monitors on the ground.

A Reuters reporter witnessed and photographed one tally list in Port Harcourt with suspiciously similar totals for registered voters at polling stations: 500, 500, 500, 500, 500, 500, 500, 500, 450. In another tally centre in the city, 17,594 valid votes were recorded out of a registered voter population of 11,757, the Reuters reporter said.

Foreign election observers also noted the peculiarities - and contacted diplomats in Abuja who called in international intervention.

U.S. Secretary of State John Kerry and his British counterpart Philip Hammond - in Switzerland for talks on Iran - issued a tough statement saying vote counting "may be subject to deliberate political interference".

"CREATE A FRACAS"

But as Buhari's lead grew, some PDP supporters from the Delta, including Orubebe, decided on a final gamble: to create a disturbance in the main INEC hall and have thugs snatch Jega from the stage, according to Nwankwo and the Abuja-based diplomat.

What the group planned to do after the abduction is unclear, the diplomat and Nwankwo said, but the confusion could have triggered nationwide violence.

"It was a desperate thing, mostly by a group of people from the Niger Delta who were in the room," Nwankwo said, describing events that unfolded publicly in the minutes after he received the SMS.

When Jega opened proceedings on the morning of March 31, Orubebe, the former Niger Delta minister, grabbed a microphone and launched into an 11-minute tirade accusing Jega of bias.

"Mr. Chairman, we have lost confidence in you," he shouted, pushing away officials trying to make him surrender the microphone. "You are being very, very selective. You are partial," he continued, surrounded by three or four supporters. "You are tribalistic. We cannot take it."

Nigerians watched, aghast, on live television.

Meanwhile, Jega's security detail was approached by unidentified individuals telling them to stand down, according to Nwankwo and the diplomat.

But the bodyguards refused.

"Some of the guards who had been guarding Jega for years demanded a written order," Nwankwo said. "But it didn't exist."

Jega then rebuked Orubebe: "Let us not disrupt a process that has ended peacefully," he said as Orubebe slumped in his chair.

"Mr. Orubebe, you are a former minister of the Federal Republic. You are a statesman in your own right. You should be careful about what you say or about what allegations you make," he said.

Later, Orubebe congratulated Buhari on Twitter, expressing his "apologies to fellow Nigerians". (Additional reporting by Daniel Flynn and Julia Payne; Editing by Giles Elgood)

Our Standards: The Thomson Reuters Trust Principles.