FARMINGTON – A Cape Elizabeth man was killed in a shooting Tuesday night at an apartment just blocks from the University of Maine-Farmington campus, and his friend has been charged with manslaughter.

Andrew Holland, 23, who graduated from UMF last month, was shot with his friend’s handgun and died at Franklin Memorial Hospital in Farmington, Maine State Police said.

The two had planned to spend the summer working at Olde Post Office Cafe on Pond Road in Mount Vernon.

“We are deeply shocked and saddened by this tragic event,” Cafe owner Bob Wallack said Wednesday. “They were stellar employees with bright futures, and our hearts go out to their families.”

State police said an autopsy on Holland will be conducted today.

Ryan Ouimet, 23, of Coltsneck, N.J., who also graduated from UMF last month, was arrested and charged with manslaughter in the shooting.

He was released on $10,000 bail Wednesday from Franklin County Detention Center in Farmington, Steve McCausland, spokesman for the Maine Department of Public Safety, said in a written statement. Ouimet is scheduled to appear Wednesday in Franklin Superior Court in Farmington.

The shooting happened about 10:30 p.m. Tuesday at the High Street apartment rented by Caroline Halloran, 23, of Acton, Mass., a 2010 UMF graduate, who also works at the Olde Post Office Cafe.

The three friends were inside the upstairs apartment when the handgun, owned by Ouimet, went off, McCausland said. Holland was taken by ambulance to the hospital, where he died.

A young woman outside the 117 High St. apartment building Wednesday morning declined to talk about the shooting. The woman winced and, just before getting in a car and driving away, said she was best friends with Holland and Halloran.

Five other UMF students at the apartment building expressed shock after learning about the shooting.

Megan Whitman and Ben Villeneuve, college juniors, live in an apartment below where the shooting happened. They were sleeping around the time of the shooting and didn’t know the students involved, said Villeneuve, 20, of Whitefield.

“We didn’t hear a shot or see any police last night. I can’t believe it,” he said.

They knew some of the other tenants, and everyone in the building was quiet and nice to each other, said Whitman, 20, of South Paris.

“It seems like such a nice, friendly community, but you just never know when something like this is going to happen,” she said.

A neighbor mowing his lawn said it was a typical college house that didn’t have any major problems.

The man, who said he was 71 but declined to give his name, said he saw police vehicles Tuesday night after his wife told him about hearing what she thought was a gunshot around 10:30 p.m.

The other three students said they were moving into their apartments Wednesday morning, which was the first day of the summer lease period, said Donna Wheeler, property manager at Foothill Management.

Andrea Bryant, 20, of Freedom said she graduated with Ouimet and Holland but she didn’t know them. “It’s terrible to think about it happening here,” she said.

Farmington Police Deputy Chief Shane Cote said there have been few complaints related to the apartment building in the past four years. They included a few loud parties and other incidents typical of a college house, he said.

Police responded to a domestic dispute in September but it didn’t involve any of the people connected to the shooting, Cote said.

Holland and Ouimet graduated in May and Halloran graduated in 2010, according to the college’s website. Holland was a dean’s list student and graduated with a bachelor’s in education.

Ouimet earned a bachelor’s in creative writing, according to the website.

UMF President Theodora Kalikow released a statement saying, “Andrew’s and Ryan’s accomplishments at UMF held great promise . . . . We mourn deeply for both our former students, and for their loving families and friends.”

The charges against Ouimet were upgraded to manslaughter after consultations with the Maine Attorney General’s Office, McCausland said. He was first charged with elevated aggravated assault.

Police refused to identify the make of the gun used. It will be taken to the State Police Crime Lab for testing, McCausland said.