In surprise testimony, a police sergeant said yesterday that the officer accused of torturing Abner Louima boasted to him of carrying out the attack shortly after prosecutors said it took place in the restroom of a Brooklyn police station.

The sergeant, Kenneth Wernick, said that Officer Justin A. Volpe, using coarse language, told him in detail how he had rammed a stick into Mr. Louima's rectum during the attack in the restroom of the 70th Precinct station house in Brooklyn.

''He said he took a stick and put it five or six inches'' into Mr. Louima's rectum, Sergeant Wernick testified, ''and took it out and put it by his mouth and teeth area, kind of like he was showing it to him.''

Sergeant Wernick's testimony, his first public account of the events, was the most direct testimony yet linking Officer Volpe to a reported act of police torture that shocked the city.

Speaking rapidly in loud tones in Federal District Court in Brooklyn, Sergeant Wernick told of a conversation with Officer Volpe that took place after dawn on Aug. 9, 1997, shortly after prosecutors say Mr. Louima was attacked with the stick by Officer Volpe while another officer on trial, Charles Schwarz, held him down.

Mr. Louima, a 32-year-old Haitian immigrant, had been arrested in a street melee outside a nightclub in Flatbush, and prosecutors say Officer Volpe mistakenly thought Mr. Louima had punched him in the disturbance.

Sergeant Wernick, who held the rank of officer at the time and is now assigned to the Fifth Precinct in Manhattan, said the conversation started with Officer Volpe's telling him, ''I took a man down tonight.''

Sergeant Wernick said Officer Volpe then told him about using the stick against Mr. Louima.

The sergeant said Officer Volpe continued his account by saying that he had hit Mr. Louima on the genitals and that he had ''held his hand over his mouth and told him if he told anybody, he'd kill him.''

''He said, 'You want to go into the bathroom and see the stick?' '' the sergeant testified as Officer Volpe, at the defense table, alternated between watching him without expression, shaking his head and writing in a notebook.

Sergeant Wernick said Officer Volpe then took him into the station house restroom to show him the stick.

Later, in another area of the station house, Sergeant Wernick said, he watched as Officer Volpe pointed the stick at another officer's face and said, ''Smell this. Smell this.''

Sergeant Wernick said Officer Volpe then pointed the stick at him and demanded to know if he could see feces on it. The sergeant testified that he saw nothing on the stick, which he said was two to three feet long.

Sergeant Wernick said he last saw Officer Volpe holding the stick outside the station house.

''We walked outside by a large Dumpster and he held up the stick,'' said Sergeant Wernick, a burly, gray-haired man, holding up his left arm to show how Officer Volpe was holding the stick, as he sat on the witness stand next to Judge Eugene H. Nickerson's bench.

He did not say what Officer Volpe did at that point with the stick, which has never been found.

''I walked away,'' the sergeant continued. ''I didn't want to be involved at any point.''

But earlier in his account, when Alan Vinegrad, an assistant United States attorney, asked the sergeant whether he had believed that Officer Volpe had committed the torture, the sergeant said he had not.

''Why not?'' Mr. Vinegrad asked.

''First of all, because I didn't think anybody would do it,'' Sergeant Wernick replied. ''And if they did it, they wouldn't talk about it.''

Sergeant Wernick said that Officer Volpe, 27, also gave him a report on the street fight that had led to the arrest of Mr. Louima and a second Haitian immigrant, Patrick Antoine.

''He said there was a big fight outside some club, they were acting like animals,'' the sergeant said Officer Volpe had told him.

He said Officer Volpe reported that ''he got punched in the face, chased a couple of people and caught somebody, but wasn't sure if it was the guy'' who punched him.

Officer Volpe is also charged with beating Mr. Antoine, who had not been in the melee, as he walked on a street near the nightclub.

Sergeant Wernick was on the list of witnesses scheduled to testify, but there had been no previous indication that he would offer such a detailed account.

Last night, he refused to discuss the case with a reporter who went to his home on Staten Island. ''I don't want to talk,'' he said. ''I don't think I'll ever want to talk. You can understand that.''

Officer Volpe's lawyer, Marvyn M. Kornberg, is to begin cross-examining Sergeant Wernick today. He is expected, among other things, to highlight admissions the sergeant made under questioning by Mr. Vinegrad that he had been disciplined eight times in his career, including twice for lying in Police Department disciplinary hearings. Most of the remaining infractions involved not being on duty when he should have been or using excessive force.

Before Sergeant Wernick took the stand, Mr. Antoine testified, and in addition to giving his version of his encounter with Officer Volpe, he told the jury about statements the officer had made to him as he took him to the same station house restroom where prosecutors say Mr. Louima had been attacked shortly before.