Michael Jackson surprised spectators in a Denver court Monday when he testified in a copyright infringement case brought by a budding songwriter who claims Jackson stole her version of “Dangerous.”

“I wrote the lyrics for ‘Dangerous,’ ” Jackson said on the fifth day of the trial in songwriter Crystal Cartier’s lawsuit claiming Jackson infringed her copyright.

Jackson said he also wrote the song’s melody.

Jackson delighted the crowded courtroom when he sang part of “Dangerous” from the witness stand and a few bars from another song to illustrate how he creates songs.

Jackson also said that no one helped him write the lyrics or melody to “Dangerous” and he never heard Cartier’s version before recording his for his Epic Records disc of the same name.

Cartier, who filed her lawsuit in 1992, claims Jackson had access to a tape recording of her song of the same name before he recorded “Dangerous.” Cartier claims that in September 1990 she left a tape at the Los Angeles offices of Epic Records. The unknown songwriter is seeking at least $ 25 million in damages.

Cartier claims she has been performing the song since 1985, with her band Love Story, and released it on her self-financed album in July 1991.

Under cross-examination, Jackson testified the only thing he heard in common between the first four bars of Cartier’s song and his own was, “We’re both saying ‘dangerous.’ “

Follow @Variety on Twitter for breaking news, reviews and more