The Congress had earlier claimed that the Gandhis were arrested by the police.
"Shri Rahul Gandhi, Smt Priyanka Gandhi and senior Congress leaders have been arrested by the UP police," the Congress said on Twitter, using the hashtag "JusticeForIndiasDaughters".
Police said they were charged for alleged violation of prohibitory orders issued under CrPC section 144.
They were also charged with violation of the orders related to the Epidemic Diseases Act, imposed in view of the COVID-19 outbreak, and booked under IPC section 188 (disobedience to order duly promulgated by a public servant), a senior Gautam Buddh Nagar police officer said.
"The two leaders and around 150 others were detained and later released on personal bonds," Joint Commissioner (Law and Order) Love Kumar told PTI.
Kumar said there was no law and order situation in the district, after the Congress leaders left for Delhi and their supporters dispersed.
Party sources said they were taken away in a police jeep and kept in a guest house for sometime after which they were released. They then headed back towards Delhi escorted by the UP police, they said.
Priyanka Gandhi also alleged that the police used lathis on the Congress workers and many of them were injured.
Rahul Gandhi earlier questioned senior UP cops under which law was he being stopped as all he wanted was to walk alone towards Hathras to meet the rape victim's family.
"Can you tell me under which law can you stop me from marching towards Hathras," he asked the police personnel.
"I want to go alone to Hathras and on what basis can you arrest me," he added, to which the cops told him that he had violated Section 188 of the IPC of disobeying orders promulgated by the government during the pandemic.
Rahul Gandhi also alleged that in India today only RSS people and Prime Minister Narendra Modi can move around.
"In today's India, only Modi can walk or travel by air. No one else can," the former party president added.
In a tweet in Hindi, he earlier said, "In times of sorrow, loved ones are not left alone. It is Jungle Raj in UP that meeting a family in mourning also scares the government. Do not be so afraid chief minister."
The 19-year-old woman was allegedly raped at a village in Hathras by four men on September 14. After her condition deteriorated, she was referred to the Delhi's Safdarjung hospital where she breathed her last on Tuesday.
She was cremated in the early hours of Wednesday, with her family alleging the local police forced them to conduct the last rites in the dead of the night.
Priyanka Gandhi said they were repeatedly stopped from going to Hathras.
"When we all started our march on foot with Rahul ji, we were repeatedly stopped and lathis were rained on us in a barbaric manner. Many workers were injured. But our intention is clear.
"The sticks of an egotistical government cannot stop us. I wish these lathis were used by this police while standing in defence of Hathras's Dalit daughter," she said in a tweet in Hindi.
She alleged that an "arrogant power" is demonstrating its power "over the dead bodies of innocent girls" and it is indulging in injustice, instead of preventing it.
"Our struggle for women will continue for a safe society and state, where they can live freely and progress," Priyanka Gandhi tweeted.
Congress leader Randeep Surjewala put out a video along with a tweet showing Rahul Gandhi allegedly being roughed.
"Lala Lajpat Rai had said that every blow of a stick on my body would prove to be the last nail in the coffin of the British Raj.
"The sticks on Rahul ji and Priyanka ji's convoy will also prove to be the last nail in the coffin of the Yogi government," Surjewala said in a tweet in Hindi.
Congress leader P Chidambaram also alleged that none of the country's laws seemed to apply to the UP police.
"UP police is a law into itself. None of the laws of the country seem to apply to it," he alleged.
"What is wrong if the leaders of a political party protest against a gruesome crime and wish to visit the victim's family," he asked on Twitter.
Chidambaram said the two leaders were not violent, they did not carry arms and they were lodging a peaceful protest. "Why should the police stop them from protesting peacefully? Why should the UP police arrest the two leaders and take them away?"
"I hope the court where the leaders will be produced will release them," he said.
Earlier in the day, the protest by the Congress workers at the Delhi-UP border had led to major traffic snarls, with hundreds of vehicles piling up at the DND flyway and along the high-speed Noida-Greater Noida Expressway.