A 17-year-old student charged over a stabbing attack on another student at Sydney's Fairfield High School has been granted bail.

Police were called to the south-western Sydney school around 2:00pm yesterday, following reports a year 12 student had been stabbed during a fight.

The school was locked down for over an hour and the 20-year-old was taken to Liverpool hospital in a stable condition while police searched for his attacker.

Police say the 17-year-old left the school after the fight and handed himself at Fairfield police station last night.

He was arrested, charged and kept in custody overnight to face the Parramatta Children's Court.

The boy's lawyer, Elias Tabchouri, told the court his client had been a victim of a protracted bullying campaign by the alleged stabbing victim.