The men, who had been in custody for a week, were shot early Friday morning as they tried to escape during the re-enactment in the southern city of Hyderabad, police said.
"They were killed in crossfire. They tried to snatch weapons from the guards but were shot dead," deputy police commissioner Prakash Reddy told AFP.
The four were accused of raping, murdering and burning the body of the woman, a 27-year-old veterinary doctor, who had parked her scooter on a busy highway in November.
The men deflated her scooter tyre and lured her to a truck yard with the promise of fixing the machine, according to police.
They allegedly then raped and murdered the woman before setting the body on fire under an isolated bridge.
The woman, who cannot be named for legal reasons, had called her sister informing her that she was scared of the men who had offered to help her before her phone went off.
The case sparked widespread demonstrations and calls for swift and tough justice, with social media swamped with demands for them to be put to death.
Shortly after their arrest hundreds of protesters also tried to storm the Hyderabad police station where the four accused were held.
At one demonstration in Delhi, some women wielded swords while in parliament one lawmaker called for the men to be "lynched" and another for rapists to be castrated.
Several hundred people flocked to the scene of the men's deaths on Friday, setting off firecrackers to celebrate and showering police with flower petals.
The victim's sister also welcomed the killings.
"I am happy the four accused have been killed in an encounter. This incident will set an example. I thank the police and media for their support," the sister told local television station.
There were other reports of people celebrating the shootings from several parts of the country.
However rights activists accused the government of using "arbitrary violence" to avoid accountability.
Police in India are often accused of using extra-judicial killings to bypass the legal process, often as a cover-up in botched investigations or ot pacify public anger.
"This is absolutely unacceptable," lawyer and activist Vrinda Grover told AFP.
"There must be accountability of the police. Instead of investigation and prosecution the state is committing murders to distract public and avoid accountability," she said.
More than 33,000 rapes were reported in India in 2017, according to the latest government figures, but vast numbers go unreported, experts say.
At the same time, a huge backlog of cases in the highly inefficient Indian criminal justice means that many victims wait years for their attackers to be convicted.