Tax avoider and “non-filer’s syndrome” sufferer Charles O’Byrne, who just a week ago was one of the most powerful men in state government, had no allies at the end.

The ruthless ex-Jesuit priest and top adviser to Gov. David Paterson was forced out Friday when his boss – his only real ally – decided the public humiliation over O’Byrne’s failure to pay $300,000 in taxes, allegedly because of bouts with depression, was too much of a liability.

“He got where he was with sharp elbows, like Eliot Spitzer, and like Eliot, no one will step up for him,” said a colleague and Albany insider.

O’Byrne’s rise to power was a combination of wits, driving ambition and more than a little luck.

The Manhattan-born former confidant to Paterson grew up middle-class in New Jersey, the son of a public-school teacher and psychologist.

Now openly gay, O’Byrne delayed his decision to join the Catholic priesthood over the celibacy requirement, he wrote in a 2002 article for Playboy.

Instead, he went to Columbia College and Columbia Law School, where he struck up a lifelong friendship with Stephen Smith Jr., the daughter of John F. Kennedy’s sister, Jean Kennedy Smith.

After graduation from law school in 1984, O’Byrne worked as a corporate litigator with the firm Rosenman & Colin.

He once wrote he had “had my share of casual sex and two serious relationships” before committing to life as a priest in 1989. That year, he claims, he was expelled from St. John Neumann Resident and Hall seminary in New York Archdiocese because he reported his colleagues’ anti-Semitism.

He undertook Jesuit training at three other schools before being ordained in 1996.

Throughout this time, he also acted as a spiritual adviser to the Kennedy clan – especially during the 1991 rape trial of William Kennedy Smith.

Upon ordination in 1996, he officiated at the storybook wedding of John F. Kennedy Jr. – and then again at his funeral three years later.

Money may never have been a great worry.

O’Byrne got regular payments from Jean Kennedy Smith, the mother of his Columbia friend Stephen, for managing her trust fund as well as for helping manage another trust fund for Kennedy heir Kym M. Smith.

O’Byrne also stumbled upon Ethan Geto, a gay activist and lobbyist who was running the New York operations of Howard Dean’s presidential campaign in 2003.

Despite O’Byrne’s lack of political experience, Geto put him to work as a paid policy analyst and speechwriter.

“He was a natural,” one campaign veteran recalled, adding that O’Byrne seemed to just love the work. Then Dean screamed and dropped out, and O’Byrne needed a new calling.

It just happened that Paterson, then the minority leader in the state Senate, was looking to hire when Geto introduced him to O’Byrne. That year, O’Byrne became a speechwriter for Paterson and then the next year, director of communications.

But it was in late 2005 and early 2006 that O’Byrne began reaching for power.

Paterson’s chief of staff at the time, Michael Jones-Bey, took an extended leave of absence when his wife miscarried.

“Charles just stepped in and started running things. He made sure [Jones-Bey] was as neutered as possible, and Michael never came back to work,” a colleague recalled. “He didn’t have a title anymore. He was pushed out.”

O’Byrne became secretary, or chief of staff, in January 2006, and Paterson rose to lieutenant governor and governor.

“He systemically pushed out everyone with a long-term relationship with David and basically became David’s baby sitter. He became the only gatekeeper for David, and everyone had to go through him to get to David,” the Albany insider recalled.

“He would tell us, ‘You’ve met with me, so you can tell the press you met with the governor,’ ” one Assembly aide recalled.