A 52-year-old man has been sentenced to life in prison for shooting his best friend in the back of the head as he was sitting on a sofa in his apartment.

Peter Donnelly, of The Green, Larch Hill Apartments, Santry, Dublin, had pleaded not guilty to the murder of Edward Flanagan in June 2011.

A jury at the Central Criminal Court convicted him by a majority verdict of 11-1 this afternoon.

Donnelly had also admitted possession of an automatic pistol and three rounds of ammunition.

The day before the shooting, Mr Flanagan and Donnelly had been drinking cans of beer in a field at the back of Belcamp College with two others, before going back to Donnelly's apartment.

They continued drinking there and watching films in the living room.

However, a dispute arose and Donnelly left the room, came back with a handgun, walked around the back of the sofa and shot Mr Flanagan in the back of the neck.

Neighbours heard the shots and called gardaí.

The first garda could not get in, but the door to the apartment was rammed after he leaned over a neighbour's balcony and saw Mr Flanagan slouched on the couch with a can of beer in his hand.

The garda said that what appeared to be blood was coming from Mr Flanagan's head.

Donnelly voluntarily went to Coolock Garda Station later that morning and told gardaí he discharged the gun that shot Mr Flanagan.

He initially denied possession of a Baikal 9mm automatic pistol and three rounds of .38 ammunition, but changed his plea to guilty on these charges during the trial.

Mr Flanagan's sister, Marie, said it was difficult to accept that such a kind and helpful father could be so brutally murdered.

She said his 12-year-old son never got to say goodbye to him and there was no one there to do the normal fatherly things with him.

Detective Garda Shay Woods told the court that Donnelly may have killed Mr Flanagan because people were refusing to leave his home and Mr Flanagan was sitting back enjoying the party.

Mr Justice Paul Carney sentenced Donnelly to the mandatory term of life in prison.