Crime is rising at an alarming pace across the city — with increases in every borough for the first time in nearly 20 years, The Post has learned.

Major felonies are up 4.2 percent citywide, fueled by a frightening uptick in shootings, sex crimes and street robberies, according to NYPD statistics for the year to date compared with the same period in 2011.

The only silver lining is a decrease in murders, which were down 15.6 oercent, from 212 to 179.

The NYPD divides the city into eight “patrol boroughs” — and crime has gone up in each one for the first time since at least 1994, sources said.

The numbers have also been driven by increasing thefts of pricey gadgets, which push up the grand-larceny numbers.

“One big issue is people being careless with their electronics. People are not paying attention to their surroundings,” a source said.

Another source added, “They’re expensive, and people are wearing them in public . . . All these new electronic devices are grand larcenies, and that’s what is partly driving up the numbers.’’

The rise also reflects the NYPD’s decision to be more selective using stop and frisks, which cops call “250s.”

“Before [precinct commanders] were yelling, ‘How many 250s you got? How many 250s you got?’ Now they’re saying ‘You have to stop the right people,’ ” a source said. “You also have less cops out on the street. And eventually, when the word gets out that we’re not going to do any stop and frisks now, crime’s going to go up even more.”

The figures show there have been 1,586 misdemeanor sex crimes so far in 2012, a nearly 20 percent hike over the 1,323 during the same period in 2011.

The number of people shot jumped from 647 to 695, a 7.4 percent increase, while “shooting incidents” — where no one is hit — rose from 536 to 587, a 9.5 percent increase.

Grand larcenies spiked from 16,397 to 17,916, or 9.3 percent, while auto thefts dropped 11.3 percent, from 3,953 to 3,508.

Rapes were up from 656 to 670, a 2.1 percent increase, while felony assault rose 1.1 percent, from 8,332 to 8,422.

Although murders are down, a source noted that “people are still getting shot — but they’re not dying as much. Modern technology.”