Britain took a 2-1 lead into Sunday after Murray completed his singles win over Andreas Seppi on Saturday and then teamed up with Colin Fleming to beat Fabio Fognini and Simone Bolelli in a tense doubles clash.
That left Murray knowing a 20th consecutive singles win in Davis Cup against Fognini would send Leon Smith's team through to a first semi-final since 1981.
But Fognini is one of the best players in the world on clay and his extra nous on the surface came to the fore as he triumphed 6-3 6-3 6-4.
The tie therefore came down to a clash between world number 34 Seppi and Ward, ranked 161st.
The Londoner has caused some memorable upsets in Davis Cup, but found Seppi far too solid and the Italian won the tie with a 6-4 6-3 6-4 victory.
Fognini's volatile side had been to the fore over the first two days and he was in full gesticulating mode at the start on Sunday as Murray broke serve in the first game and moved into a 3-1 lead.
But Fognini began to show the huge talent he possesses and he reeled off five straight games to take the first set.
The Italian has won three clay-court titles in the last year and more matches on the surface than Rafael Nadal during that period, while Murray has never made a final on clay.
He had two chances to break Fognini in the sixth game of the second set, but the world number 13 held on and then broke Murray twice in succession, the Scot ending the set with a double fault.
Murray looked weary, not surprising given the amount of tennis he played on Saturday, while he had been laid low before the tie because of a stomach virus.
The third set was tight as well, but Fognini always seemed to have the upper hand and he struck with Murray serving to stay in the match.
The Wimbledon champion saved two match points, but found the net on the third to send the raucous Naples crowd into raptures.
It was Murray's first singles defeat in Davis Cup since losing to Stanislas Wawrinka in 2005.
The British number one was magnanimous in defeat, telling the BBC: "He played some great stuff at important periods and that was the main difference really.
"When I had my opportunities I was a little bit disappointed in myself. When he had his he was exceptional, so credit to him."
Murray refused to blame his heavy schedule, saying: "I was tired when I got up, but I felt okay once I got out there. I did okay physically in the match. I've definitely felt worse in matches on clay."
The key moments of Ward's match against Seppi came in the first set.
The Italian has not had a good season so far and has a reputation for struggling with nerves, and that seemed to be borne out as three times Ward retrieved breaks of serve.
The last came when Seppi served for the set at 5-3, but a rain break did not help Ward as he promptly dropped serve for a third straight time to lose the set.
One break of serve for Seppi, in the sixth game, was enough for him to take the second set and the end was nigh when he moved 4-1 ahead in the third.
To Ward's credit, he kept fighting and saved a match point at 3-5 but Seppi stayed strong and served out the win impressively.
Britain's win over the United States in February ensured they would play in the World Group again next season.