BROCKTON — A Brockton murder defendant’s desire to keep his gay relationship on the down low may have motivated him to kill his former lover, according to the prosecution.

Kian Willis, 21, of Brockton, was arraigned on a charge of murder late Wednesday afternoon at Brockton District Court following his arrest by Brockton police at 2 p.m. Willis is being accused of pulling the trigger, or at least being part of a joint venture, in the fatal shooting of 27-year-old Patrick Sequeira-Ferreira on Nov. 12 on Keith Avenue in Brockton.

Plymouth County Assistant District Attorney Jessica Kenny told the court that text messages show how Willis lured Sequeira-Ferreira outside right before the shooting, falsely telling the murder victim that he arranged him an Uber ride. Willis was the last person to have contact with the victim by phone, Kenny said. Then, there were three gunshots, recorded by the city’s ShotSpotter system, Kenny said.

Willis was later interviewed by police, and he expressed concerns about people finding out about the nature of his sexual relationship with Sequeira-Ferreira Kenny said. On top of that, the prosecutor said, Willis was worried that he could lose his job, working at the Office of Community Corrections, a subset of the state’s probation department. That’s where Willis originally met the murder victim, who was a client of the agency, Kenny said.

“They struck up a friendship, which was against the policies and rules of the OCC,” said Kenny, as Willis hid himself from view, standing behind a partition on the side of the court room. “The defendant also told police that he had sexual relations with the victim previous to that. It appears that no one in the defendant’s family may have been aware that he was homosexual and bisexual. It appears that the defendant before you may have been concerned that the victim was going to tell people about their relationship.”

Judge Julie Bernard ordered Willis to be held without bail. Willis, who pleaded not guilty, is now due back in court on Jan. 2 for a probable cause hearing.

Willis was represented by Boston-based defense attorney Christopher Belezos, who was granted requests to defer his argument for bail and to preserve notes made during the course of the murder investigation.

During the arraignment, family members of Sequeira-Ferreira consoled each other and looked on quietly. They walked in together, and his mother wore a button with the 27-year-old’s picture on it, but they declined to comment about Tuesday’s arrest in the murder case.

Sequeira-Ferreira was walking down Keith Avenue, adjacent to the CVS Pharmacy parking lot, when sources told The Enterprise he was ambushed from behind and shot in the head on the night of Nov. 12. The 27-year-old was rushed by ambulance to Good Samaritan Medical Center in Brockton, then flown by medical helicopter to Boston Medical Center, where he died shortly before midnight.

Kenny said surveillance video shows Sequeira-Ferreira being followed by another man, but there’s no footage of the shots being fired. Other surveillance footage then shows the suspect running down Keith Avenue toward Warren Avenue, in the direction of where Willis was picked up by another friend immediately after the shooting, based on his phone records, according to Kenny.