The boardroom battle at Papa John’s got a little uglier Sunday.

The pizza chain’s board, looking to further distance itself from the company’s controversial founder, voted Sunday to adopt a poison pill to keep John Schnatter from gaining a controlling stake in the Louisville, Ky., company, Papa John’s said on Monday.

Schnatter, who founded the company with a single oven in his father’s tavern in the 1980s, stepped down as chairman earlier this month after it was learned that he used the N-word during an internal conference call in May.

Schnatter owns 29 percent of the company — and has said he will not step away from the board. He has also said his decision to relinquish the chairman’s job was a mistake.

With the 56-year-old executive promising not to go quietly, the situation on Sunday was ripe for confrontation.

Under the poison pill, shareholders will receive the right to purchase one preferred share for every share of Papa John’s common stock they own, the company said in a regulatory filing on Monday. That right will be triggered once someone purchases 15 percent of the company’s stock without the permission of the board.

The poison pill, or shareholder’s rights plan, expires in one year — on July 22, 2019.

Amid the turmoil, shares of Papa John’s were down more than 7 percent in late morning trading on Monday, to $47.91. Shares of the pizza chain are down 36 percent this year.

Schnatter’s 29 percent stake was grandfathered in, the company said.

The founder has admitted he used the racial slur during a media training session — and quickly apologized — but said he was pushed to do so by the chain’s outside marketing firm.

After it was learned that Schnatter used the N-word, the chain found itself in the middle of a national dust-up, as several marketing partners dropped their relationship with the chain and/or Schnatter.

Schnatter had been a highly visible spokesperson for the 5,212-store chain, appearing in TV commercials and even in the company’s logo.

A special committee of the board decided to remove Schnatter’s likeness from the logo — and barred him from talking to the media. It also voided an agreement it had with the executive that allowed him to use space at its headquarters for offices and hinted that it wanted him to step down entirely from the board.

Schnatter then lawyered up — and made moves to secure his rights for what he saw as an inevitable showdown with the board. The lawyer also claimed the move to evict him from the office space was not proper.

Poison pills like the one approved by the Papa John’s board are usually put in place to thwart a move by a hostile outside investor. In this case, the hostile “outsider” is the founder.