Pacific Mercantile Bancorp took a hit from exiting the wholesale mortgage lending business last fall, a decision that slashed income for the Costa Mesa-based bank for the second quarter and the entire first half of this year.

The parent company of Pacific Mercantile Bank posted $3.4 million in net loss for the quarter, compared with a $5.6 million profit in the year-ago period. The six-month figures are a loss of $6.8 million versus net income of $6.7 million.

Shares of Pacific Mercantile’s stock fell about 5.2% during morning trading to a market value of $114 million.

The quarterly loss was largely due to a drop in noninterest income—of which mortgage banking is a key component—to $1.4 million from $9.1 million in the same period last year.

An 18% gain in interest income to $7.4 million helped offset a wider loss.

As of June 30, Pacific Mercantile had $952.1 million in assets, down nearly 10% from the same point a year ago.

Deposits totaled $749 million, down 11% year over year.

The bank had $729.2 million worth of outstanding loans at the end of June, about flat from the year-ago reading.

Pacific Mercantile said in a statement that it expects the exit from wholesale mortgage lending “to adversely affect our results of operations during the remainder of 2013.” Its long-term prospects include redeploying capital resources “to our core commercial lending business,” reducing staffing and operating costs, and to “manage and limit interest rate and other risks inherent in a residential mortgage lending business.”