NEW YORK -- In a packed New York courtroom, Ed Sheeran picked up his guitar Thursday and launched into a tune that has him locked in a copyright dispute over Marvin Gaye's soul classic "Let's Get it On" as the only audience that mattered -- a jury -- looked on.

Sheeran was an hour into testimony in Manhattan federal court when his lawyer, Ilene Farkas, pressed him to tell how he came to write "Thinking Out Loud" a decade ago.

He reached back, grabbed his guitar from a rack behind the witness stand and explained that writing a song was second nature to him. He said he used his own version of phonetics to create songs so quickly that he could write up to nine in a day. Even last weekend, Sheeran claimed, he wrote 10 songs.

Then he sang just a few words of the pivotal tune, bringing smiles to the faces of some of the spectators in the courtroom of Judge Louis L. Stanton.

"I'm singing out loud," he sang, loud enough to be heard but not raising decibels in the court.

After he finished singing those words, he spoke a few too, saying "and then words fall in" as he tried to teach the jury his method of creating music. He said he collaborated on the song with a co-writer, Amy Wadge, who wrote the opening chords.

Though he's performed with some of the world's great artists and become a regular at music award shows by age 32, he said from the witness stand with his chair tilted toward the jury: "I'm not the world's most talented guitar player."

And when he bumped his hand against the witness stand microphone, he said a quick "sorry."

Then he launched into the song that heirs of Ed Townsend, Gaye's co-writer on "Let's Get It On," say has "striking similarities" and "over common elements" to the famed 1973 Gaye musical treasure.

"When your legs don't work like they used to," he sang earnestly, like he might go deeper into the song. Then, after just a few bars, he abruptly placed the guitar back in the rack behind him as his lawyer told the judge it was an appropriate spot to adjourn for the week.

Two days earlier, he had been called to testify by attorneys for the plaintiffs and was adamant in telling jurors that he and Wadge came up with the song without copying anyone else's music.

He had also said a video that showed he had segued on stage between "Thinking Out Loud" and "Let's Get It On" was not unusual, adding it was "quite simple to weave in and out of songs" that are in the same key.

On Thursday, his lawyer posed friendly questions, eliciting from Sheeran how he became interested in music after joining a church choir with his mother when he was 4.

Sheeran appeared self-deprecating as he told his story, saying: "I can't read music. I'm not classically trained in anything."

He said he quit school at 17 so he could perform up to three times a night, playing anywhere that would have him, from bingo halls to restaurants to "anywhere nobody was."

Within a decade, he was performing with some of the biggest names in music, from Taylor Swift to the Rolling Stones, 50 Cent to Eric Clapton.

Before long, he said, he was writing eight or nine songs a day, explaining: "When inspiration hits, you get excited and it just comes out."

Near the end of his testimony, Sheeran was asked by his lawyer why an expert called by the plaintiffs had tried to show how chords in "Thinking Out Loud" resemble "Let's Get It On."

"He was saying that because it helps his argument," Sheeran said.

The trial resumes Monday.