SHAFTER, Calif. — Scattered on either side of Shafter Avenue just north of the town center here, new oil pump jacks, some bobbing and others thrusting, tower above this corner of California’s prime farmland.

A dirt side road, flanked by an orchard of two-year-old almond trees and a field of alfalfa plants, leads to a two-acre patch where workers were drilling a third well. At a larger rig not too far away, next to a field of potatoes, a 50-foot-tall tower flared off the gas from the crude being extracted from land that used to be a rose field. At yet another site next to almond trees, a fence now surrounds an area where liquids from hydraulic fracturing, the drilling technique commonly known as fracking, leaked into an open pit.

Driven by advances in drilling technology and high oil prices, oil companies are increasingly moving into traditionally agricultural areas like Shafter that make up one of the world’s most fertile regions but also lie above a huge untapped oil reserve called the Monterey Shale. Even as California’s total oil production has declined slightly since 2010, the output of the North Shafter oil field and the number of wells have risen by more than 50 percent.

By all accounts, oilmen and farmers — often shortened to “oil and ag” here — have coexisted peacefully for decades in this conservative, business friendly part of California about 110 miles northwest of Los Angeles. But oil’s push into new areas and its increasing reliance on fracking, which uses vast amounts of water and chemicals that critics say could contaminate groundwater, are testing that relationship and complicating the continuing debate over how to regulate fracking in California.