It was an unexpected moment — and one of the first signs Target’s tech department was in line for a major shake-up.

Not long after taking over as Target’s chief information officer, Mike McNamara told his boss, CEO Brian Cornell, that his budget was too big.

“For the first time perhaps in my career, I had someone walk into my office and say, ‘Brian, I’ve got too much capital to spend,’ ” Cornell recounted incredulously to Wall Street analysts at a meeting in New York earlier this year. “ ‘I want to give you some dollars back.’ ”

As in hundreds of millions of dollars back.

McNamara, 52, arrived last June from British-based grocer Tesco as one of the key outside appointments to Cornell’s executive team. He immediately stood out, in part because of his passion for opera, his Irish accent and penchant for using superlatives such as “bloody” and “brilliant.”

He quickly ushered in a completely new direction for Target’s IT department. He identified three main weaknesses: Target had outsourced too much of its tech talent. Its systems were too unstable. And it was working on too many projects.

“We were just doing too many things,” he said in an interview at his downtown Minneapolis office. “I mean we had over 800 projects. Even a company as big as Target doesn’t have 800 priorities.”

The list has now been pared back to 80.

And in an abrupt shift following thousands of headquarters layoffs last year, McNamara has taken Target on a hiring spree aimed at making the company into an engineering powerhouse instead of relying on contractors. In the past year, Target has hired about 700 engineers, many of them based out of the company’s offices along Nicollet Mall and in Brooklyn Park. About one-quarter of the new recruits work at its offices in Bangalore, India.

Target currently has about 800 more open tech positions.

“I could easily fill another thousand positions,” McNamara said. “We need to have a much stronger engineering capability than we had, and we need to own it. We need to own our technology.”

McNamara’s efforts, as well as the clout he holds within Target’s C-suite, is yet another sign of a new era in retailing.

For years, it was the flashy marketers and product designers who ran the show at Target, while tech folks were more of an afterthought. But as online shopping has disrupted the entire industry, technology and supply chain, which are the key ingredients in Amazon’s meteoric rise, have become more central to the company’s mission.

“They will be the new battlegrounds for retail over the next decade,” McNamara said. “Whoever has got the best technology and the best supply chain has the best chance of winning.”

Those are also the areas where Target needs the most work.

Cutting interruptions

When Target’s systems fail, it’s often quite obvious and embarrassing.

If its point-of-sale systems freeze, it means delays in the checkout lanes. Since McNamara’s restructuring, Target says the number of incidents involving those disruptions has been cut in half.

Incidents involving the handheld devices employees use to look up products for customers have been reduced about fivefold.

Yet McNamara said Target needs to continue to improve its website.

Target.com has notoriously crumbled under the pressure of some of its biggest moments, such as last year’s popular designer collaboration with Lilly Pulitzer (before McNamara came on board).

On Cyber Monday last year, after McNamara was on board, Target.com offered an eye-popping 15 percent sitewide sale. Traffic was much higher than forecast, swamping the site. Target ended up putting shoppers into virtual waiting lines, frustrating legions of customers who took to social media to complain — loudly.

“It was glorious defeat,” said McNamara, candidly. “But it was defeat. It’s not good enough. We’ve got to do better this year.”

Take-charge style

McNamara’s predecessor, Bob DeRodes, was in the role for a year. He was brought in to help Target get back on track following the company’s massive data breach in late 2013.

An engineer by training, McNamara has been working closely with John Mulligan, Target’s chief operations officer, who has been leading the effort to reduce the amount of out-of-stock merchandise and to modernize Target’s supply chain, which was not built to handle the demands of online shopping.

“He’s brought focus and clarity,” Mulligan said of McNamara. “And I think he’s brought confidence back to the technology team where it was waning before.”

Mulligan recalled the hourslong meeting in December when McNamara convened all of Target’s top executives to a room where they pared back the list of 800-plus technology projects. Each item was weighed against the company’s strategic priorities for growth.

“Post-it notes that came off the board meant they weren’t getting done,” at least not this year, Mulligan said. “Others went up — that meant they were getting done.”

Projects left on the cutting room floor included a long-hoped-for new intranet for headquarters, new human resources and finance systems and pilot programs such as curbside pickup.

Bringing it in-house

When McNamara came to Target, about 70 percent of its technology work was being outsourced — not unusual. Target used its IT staff mostly to integrate and implement packaged software it bought from vendors.

“It was about plugging together Lego bricks that we bought from other businesses,” McNamara said. “Those Lego bricks are just not good enough for us anymore. The packaged software that used to run our website isn’t man enough for the job. We need to write those ourselves. We need to write our own e-commerce engine.”

The company started to do that even before McNamara. Target had famously outsourced its website to Amazon for a decade, taking control of it back in 2011, only to have it crash shortly after the launch of its limited-time-only collaboration with Missoni.

“The way that website was rolled out the first time was sad — that’s the only word I can use for it,” said Paula Rosenblum, managing partner of Retail Systems Research. “It had a lot of people shaking their heads. It was well below any reasonable standard.”

Target’s post-Amazon website was built off software from IBM.

“We just outgrew that very, very quickly,” McNamara said. “So over the past two or three years — it preceded me — we’ve been writing our way out of that position. We’ve been writing our own code to replace the packaged code.”

A couple of months ago, the company rolled out a revamped website that, among other things, now adjusts itself depending on whether customers are using desktops or phones.

That enhanced website was made possible by the influx of engineers Target has brought in over the last year. Now, about 3,000, or nearly 70 percent, of its 4,500 tech department employees are Target employees, a complete flip of its previous position.

To fill those jobs, Target stepped up recruiting on college campuses and at tech conferences. In the process, Target is having to overcome some of the lingering negative perceptions about its technology prowess. But McNamara is pleased with the company’s hiring success so far, especially since about one-third of the recent engineering graduates it has hired are women.

As for the buzz earlier this summer when Amazon opened a tech office in downtown Minneapolis, McNamara acknowledged he may initially lose some of his engineers to the online giant.

“But perversely, I’m quite excited about it,” he said. “In the long term, I think it will be good for the Twin Cities because I think it will be a magnet for technical talent.”

And, he added, Amazon has a reputation for churning through people. So down the road, some of those people might end up at Target.