Haines made 123 and Brown 105 as they shared a stand of 219 for the second wicket, the county’s fourth highest partnership in one-day matches, out of a total of 333 for four after Haines had won the toss.
With Travis Head and David Wiese adding 54 off 21 balls at the end, Sussex finished with their second highest List A total in matches at Hove after plundering 130 off the last ten overs.
Middlesex, who needed to win to have any chance of qualifying for the knockout stages, were in a decent position on 145 for one in the 28th over, but Sussex’s four slow bowlers maintained pressure and wickets began to fall, including opener Max Holden who top scored with 94.
But left-hander Jack Davies made a rapid 51 off 37 balls and even when he departed in the 46th over Martin Andersson kept his side in the hunt. Middlesex took 23 off the penultimate over from Danny Ibrahim and when Andersson hit Wiese for six off the first ball of the final over they needed eight off five balls and were favourites.
But Wiese held his nerve. He had Josh De Caires (21) caught in the deep and conceded singles off the last three deliveries to see his side home. They swapped places with Middlesex to finish seventh in Group 2.
Haines and Brown had earlier come together in the eighth over after Middlesex captain James Harris held a catch off his own bowling to dismiss Ali Orr for 13.
It was the last success Middlesex enjoyed for 36 overs as Haines and Brown built their partnership in ideal batting conditions. The only chance either of them offered came when Haines was dropped on 117. He struck 11 fours and four sixes with only De Caires going for less than five runs an over.
Haines made 123 from 131 deliveries before he was caught at deep mid-wicket off a mis-timed pull and Brown also departed to a standing ovation when he holed out to deep extra cover, his runs coming off 109 balls with eight fours. Head and Wiese then thrashed 54 from just 21 balls, 46 of which came in boundaries, Wiese making 33 off 11 and Head 46 from 20.
Middlesex made a solid start with Holden sharing 65 with Steve Eskinazi (28) and 80 with Varun Chopra (45), but the required rate had climbed to nine an over by the time skipper Peter Handscomb was lbw sweeping James Coles for 16.
Holden moved to 94 from 95 balls with 12 fours when Head took a sharp return catch to end a fine innings. The Australian off-spinner finished with two for 35 while Wiese and Will Beer also picked up two wickets.
Haines said: "It was a tremendous game of cricket. We've had a few close ones in this competition and it's great to come out on the right side. It was nice to get my first List A hundred as well. I think Browny and I compliment each other nicely, because he hits the ball in areas I don't and the other way round. The family were all watching so that was nice for me, it was my Dad's birthday as well so hopefully that was a nice birthday treat for him."