A man died of a gunshot wound to the head Monday after a confrontation with his ex-girlfriend and another man in San Rafael, police said.

The case appears to be a suicide but the investigation is continuing, said San Rafael police Lt. Alan Piombo.

The name of the dead man was not released Monday pending the notification of family members.

According to the preliminary investigation, a woman who lives in the 200 block of Canal Street went to a nightclub with a male friend on Sunday evening. Her ex-boyfriend approached at the club and asked her to dance, and she declined.

The ex-boyfriend left the club, but he showed up at her apartment early Monday morning, and the other man from the nightclub was there with her. An argument ensued, and the ex-boyfriend fired a gun at the other man’s head, Piombo said, citing the witness statements.

The man ducked and the shot missed. The ex-boyfriend then turned the gun on himself and fired.

An occupant of the apartment called authorities. A member of the San Rafael Fire Department pronounced the ex-boyfriend dead.

Piombo said the woman’s roommates were in their bedrooms at the time and heard a commotion but did not witness the shooting.