NEW YORK (AP) _ Five thousand police officers lined bitterly cold streets outside a Brooklyn church Tuesday for the funeral of the first New York police officer killed on duty in the city this year.

Officer Robert E. Machate was shot to death March 3 while struggling with a suspect in Brooklyn. Two men, both illegal aliens, were arrested shortly afterwards.

At the funeral Mass, Mayor Edward I. Koch and Police Commissioner Benjamin Ward expressed hope the state Legislature would override Gov. Mario Cuomo's promised veto of bill to reinstate the death penalty.

''What's required here is that every criminal in the street know that you're gonna be apprehended, that you're gonna be prosecuted, that you're gonna be jailed and where appropriate, executed,'' a visibly angry Koch told mourners packing St. Mark's Roman Catholic Church.

The state Assembly in Albany passed a death penalty bill Monday, and Cuomo promised to veto it.

Outside St. Mark's, the police officers, most from metropolitan area forces, formed a four-block long blue line.

As Machate's coffin was carried out of the church by an honor guard, three police helicopters in a ''missing man'' formation swooped over the church.

Officer Steven McDonald, who was paralyzed when he was shot while on duty, attended the services in his wheelchair.

Machate, was was 25, had been baptized and married in the same church. His wife, Grace Ann, seven months pregnant with the couple's only child, wore a miniature version of her husband's shield around her neck during the service.

Machate had earned 13 awards since joining the force in 1986.

''Robert Machate was intensely proud to be a police officer,'' said the Rev. Gerard J. Arella, noting that the slain officer came from a police family. ''He and his family were all proud to be servants of the people.''