DETROIT - A series of often-explicit text messages from Mayor Kwame Kilpatrick's former chief of staff appear to show that she had a long-term romantic relationship with him and that he played a role in the firing of a police officer who sued the city.

The embarrassing messages between Kilpatrick and Christine Beatty from 2002 and 2003 appear in an 18-page document released yesterday on the orders of Wayne County Circuit Judge Robert J. Colombo Jr. in response to a lawsuit by the Detroit Free Press and the Detroit News.

The document was obtained from the computer of Michael Stefani, an attorney who represented three police officers in whistle-blowers' lawsuits against the city that were settled last year for $8.4 million. The text messages were taken from Beatty's city-issued pagers.

The messages could prove damaging to Kilpatrick and Beatty, who are accused of lying under oath in one of the lawsuits by denying that they had an intimate relationship. They are charged with perjury, misconduct, and obstruction of justice.

The Free Press published some of the text messages in January. Wayne County prosecutors began the perjury investigation after those excerpts were released.

The document released yesterday includes descriptions of sexual trysts, the frequent use of the N-word by the mayor and Beatty as a term of endearment, and discussions of marriage.

The text messages also appear to show that Kilpatrick was involved in the decision to fire one of the former officers, former Deputy Chief Gary Brown, which Kilpatrick also denied under oath as part of the lawsuit.

In a text message to Kilpatrick on May 15, 2003, Beatty said: "I'm sorry that we are going through this mess because of a decision that we made to fire Gary Brown."

Kilpatrick said last September that the city would appeal a jury's verdict in favor of two officers in one of the lawsuits. But after Stefani gave one of Kilpatrick's lawyers a motion for attorney's fees that contained excerpts of the text messages, the suit was settled and the motion was never filed in court.

The judge said yesterday that he had agreed to release the document because he believed it directly led to the deal that was reached between the former officers and the city.

Kilpatrick, after a community forum yesterday evening, questioned the authenticity of the messages and said their release did not provide "the smoking gun" some had expected. "All the lawyers have testified that this had nothing to do with the settlement," he said.

Mayer Morganroth, who represents Beatty, said that he believed the text messages were obtained illegally and that the excerpts should not have been released.

Kilpatrick, 37, remains married to his wife, Carlita. Beatty, also 37, left her husband at the end of April 2003, according to the document.