The deputy heard children yelling, authorities said, then a crossing guard came over and told him - a man with a gun was walking near the elementary school.
Deputy Troy Zellman saw the man, later identified as Dillon Conn, 24, of Riverview. About 2:30 p.m. Tuesday, Conn was walking north on Ramble Creek Drive outside Sessums Elementary School in Riverview.
In Conn's right hand was what looked like a semi-automatic handgun, the Sheriff's Office said. He looked "agitated."
Zellman drew his weapon and told Conn to stop and put down the gun, the Sheriff's Office said. Conn refused, and told the deputy he was going to have to shoot him. Zellman repeated his order. This time, Conn complied, dropping the gun to the grass.
As Zellman handcuffed him, the Sheriff's Office said, Conn repeatedly said he wanted the deputy to kill him, that life wasn't worth living anymore.
A few minutes later, Zellman walked over to Conn's gun. Upon closer inspection, he realized it was a gas-powered BB pistol. It did not have a red tip or other marking to indicate it wasn't what it looked like - a semi-automatic handgun.
"Fortunately, the guy's not dead. He could have very easily been killed, and that's what he wanted," said Hillsborough County Sheriff's Office spokesman Larry McKinnon.
Zellman was working at Sessums because the Sheriff's Office and Tampa police have posted deputies and officers at each of the county's 150 elementary schools through the end of the school year in response to December's tragedy at Sandy Hook Elementary School in Newtown, Conn.
"Had this guy got on the school grounds, there's no telling what may have happened," McKinnon said.
Conn was arrested on a charge of exhibiting a firearm within 1,000 feet of a school, a felony, and ordered held on $25,000 bail at the Hillsborough County Jail.
State records show Conn has 12 previous arrests, dating to when he was 16.
Many of the cases were not prosecuted, state records show. But Conn has been convicted of petty theft and battery on health care personnel, and twice of violating domestic violence injunctions.
He also was cited in 2011 with trespassing at Sulphur Springs Elementary School in Tampa, jail records show, and served nine days in jail.
News researcher John Martin contributed to this report. Will Hobson can be reached at (813) 226-3400 or firstname.lastname@example.org.