A Indian court on Tuesday granted bail to a climate activist who was charged with sedition after distributing a document intended to help protesting farmers organize.

The case of the activist, Disha Ravi, 21, is the latest test of the independence of India’s judiciary amid a turn toward nationalism under Prime Minister Narendra Modi, whose agriculture policies are at the heart of a monthslong protest by the country’s farmers.

Ms. Ravi was arrested at her home in the southern city of Bangalore on Feb. 13. She was later accused of distributing an online instruction manual known as a “tool kit” in the form of a Google Doc with talking points and contact information for influential groups. The authorities say it led to violence during a protest in Delhi last month.

Her arrest prompted outrage from former police officers, retired government officials and public intellectuals, who accused Mr. Modi’s government of using the country’s law enforcement agencies to target political opponents.

Thousands of farmers have been camped on the capital’s outskirts since November to protest a slate of new laws that would dismantle a subsidy system that has for decades protected them from the vagaries of the free market.

Although the protests have largely been peaceful, violence erupted on Jan. 26 in New Delhi. Dozens of farmers and police officers were injured, and one person was killed.

Ms. Ravi’s activism was previously associated with the climate movement started by the 18-year-old Swede Greta Thunberg. The tool kit, which international activists say is a commonly distributed document, was brought to the attention of the Indian authorities after Ms. Thunburg tweeted it in solidarity with the Indian farmers.

The Delhi police, investigating the violence at the Jan. 26 protest, said the goal of the document was to spread unrest and “defame” the country.

“If highlighting farmers’ protest globally is sedition,” Ms. Ravi told the court, “I am better in jail.”

On Tuesday, Judge Dharmender Rana of the Delhi Sessions Court said there was little reason to detain Ms. Ravi, and questioned the prosecution’s logic in connecting the tool kit and the violence.

The judge set Ms. Ravi’s bail at about 100,000 rupees, or $1,370, with the condition that she remain in Delhi.