Her campaign against a controversial security law had led to her being detained, and forced fed through a tube in her nose, for over a decade.
She was held under a law that makes attempting suicide a crime.
The court in northeastern Manipur state granted her bail on Tuesday and asked her to reappear on 23 June.
Ms Sharmila has signed a personal bail bond and is expected to be released after bail procedures are complete.
It is not clear when she will formally break her fast.
Ms Sharmila told the court in the state capital, Imphal, that she was a "prisoner of conscience" and she wanted to end her fast, be free and fight in local assembly elections.
"I have to change my strategy. Some people are seeing me as a strange woman because I want to join politics. They say politics is a dirty, but so is society. I want to stand in the elections against the government," she said.
She told reporters she had decided to "try a different [form of] agitation" because "I have been fasting for 16 years and I have not got anything from it yet".
Ms Sharmila had been protesting against the Armed Forces Special Powers Act (AFSPA), which gives soldiers sweeping powers to arrest without warrants and even shoot to kill in certain situations.
AFSPA is in effect in several Indian states, including in Manipur and Indian-administered Kashmir.
A hunger strike in pictures
Photographer Ian Thomas Jansen-Lonnquist has closely followed MS Sharmila's journey over the past few years.
She started her fast 16 years ago after 10 civilians were killed by Indian soldiers in Manipur.
She has spent most of the last 16 years in judicial custody in a hospital in Manipur's capital, Imphal, where she was force-fed a cocktail of medicines and baby formula.
Ms Sharmila was released in August 2014 after the court rejected the charge that she was "attempting to commit suicide". But she was re-arrested two days later after she refused to end her protest.
Ms Sharmila appeared in the Manipur High Court every two weeks to reaffirm her protest.
Her protest has won her worldwide recognition, with Amnesty International describing her as a prisoner of conscience.
The activist received considerable attention from local and international media outlets in recent years.
Ms Sharmila has the support of women and civil rights groups in the state.
A memorial has been built at the site in Manipur where the 10 civilians were killed by Indian soldiers. The state has a population of about 2.5 million people and a huge force of army, paramilitary and state police are deployed there to fight insurgent groups.