A failing student who offered his professor £5,000 in cash in an attempt to pass his degree has been jailed for 12 months.

Yang Li, 26, had a loaded replica gun and the money in his pocket when he went to meet Professor Andrew Graves at the University of Bath, Bristol crown court heard.

Li had been given a mark of 37% in his dissertation, short of the 40% needed to pass. Graves told him he could resubmit the 12,000-word essay, appeal against the mark or accept it and withdraw from the course.

But Li offered a fourth option, the court was told. He told Graves: "I am a businessman," and placed £5,000 in cash on the table in front of him. "You can keep the money if you give me a pass mark and I won't bother you again," Li was alleged to have said.

Graves asked Li to leave but as the student put the money away, a replica handgun – loaded with six pellets – fell from his pocket to the floor, the court heard.

The judge, Michael Longman, told Li that the weapon caused fear and alarm to the professor at the meeting on 23 November last year.

"You attempted to persuade a university professor to behave in such a way that if it had been successful you would have undermined the integrity of the universities in the UK and the legitimacy of degrees from universities here, the University of Bath in particular," Longman said.

"Your bid to achieve a pass mark by offering what was a bribe to your professor was ill-conceived to the point of being a spectacular mistake and one which was doomed to fail from the start."

Li, who was studying for a masters in innovation and technology management, admitted charges of bribery and possessing an imitation firearm. He was sentenced to 12 months in prison and ordered to pay £4,880 in prosecution costs.

Prosecuting, Mark Hollier said: "The final part of the course is for students to submit a dissertation of about 12,000 words. That had to be in by the first week of September. Mr Li's dissertation was submitted that September last year. It was marked by Professor Graves. The pass mark is 40% and the mark awarded was 37%."

Li's dissertation mark was checked by external examiners from Oxford and Cambridge University and found to be correct, Hollier said.

Defending Li, Blake James said his client came from an affluent family in China where his father was a respected government official and businessman. He said Li was not a "sham student" and had come to the UK in 2006 to study for a computer science degree at the University of Bath, which he passed.

Documents show Li was progressing well in his masters course until he failed the dissertation, James said. At the time of the final module Li was working for his father's firm – earning £25,000 a year with a bonus of £11,000 – as well as studying.

"When he learned of the result of the dissertation it was a bitter blow to him," James said. "He genuinely felt he had done all right."

James said Li was concerned he would not be able to move from his expiring student visa to a tier one visa without passing his course. His current visa has now expired.

He said Li was used to carrying large amounts of cash and had the 0.177 air pistol, used for shooting practice, in his possession as he did not want to leave it in the car during the meeting.

Li sobbed in court as the sentence was handed down while his parents, wife and parents-in-law sat in the public gallery. He plans to return to China with his wife, also a University of Bath student, after his release.