The attack happened at about 8:35 a.m. at the Park Regency Apartments in the 3100 block of Oak Road, Contra Costa County sheriff's spokesman Jimmy Lee said.
The victim, a 25-year-old woman, was asleep when the suspect entered her room but woke up when he put his hand over her mouth.
He reportedly threatened her and ordered her not to scream, Lee said.
The victim struggled and was able to free herself, and the suspect fled.
The victim's front door was locked at the time, and investigators do not know how the man got into the apartment.
The suspect was described as a black man about 6 feet 2 inches tall and weighing about 200 pounds. He had facial hair and was wearing dark jeans and a black hooded sweatshirt, Lee said.
The first incident happened at the same apartment complex on June 30. In that case, a man knocked on the victim's door and asked for a glass of water. While the victim was getting him some water, the man entered the apartment and covered the victim's mouth with his hand.
The victim struggled, pushed the suspect away and screamed, which alerted her boyfriend. The man fled before police arrived.
Then on July 6, a man entered an apartment in the complex through an unlocked front door and raped a 23-year-old woman. The victim had been alone at the time and woke up to find the man in her room.
The sheriff's office is warning residents to keep their doors and windows locked and not open the door for strangers. Residents should call police if they see anyone suspicious.
The sheriff's office is also is asking anyone with information about any of the cases to call detectives at (925) 313-2625.