Hampshire, who chose to bowl, had Essex 0-1 when Nick Browne was caught off the bowling of Fidel Edwards.
Rain then caused a lengthy delay, but Cook (114 not out) and Westley (111) dominated when play resumed.
Kyle Abbott finally ended their stand, bowling Westley with the last ball of the day as Essex closed on 243-2.
England opener Cook's ton was his second of the season, with the former Test captain averaging 81.75 with the bat through five first-class innings this season.
He was ably supported by Westley, whose century was his first of the season in first-class cricket.
Hampshire could take few positives from a difficult first day, especially after a shoulder injury to fast bowler Edwards, but Abbott's late removal of Westley will leave them with some hope of limiting the hosts' score.
Essex batsman Tom Westley:
"It's good to get that first score out of the way. That first Championship hundred of the season is always nice. It was tough going, but it's pleasing to get some runs. What's most pleasing is the position we're in after being put in to bat.
"We would have wanted to bowl first in those conditions. It did nip around in the first hour and a half. It's a good cricketing wicket, but there is definitely a bit in it for the bowlers, but also if they miss their length you feel you score.
"I don't think Cookie will mind me saying we both played and missed. On another day you can nick them and we can be 100 for three or four. But sometimes you have to ride the luck and Cookie's was a chanceless hundred. They bowled well at him, so it wasn't easy going. It's great having him at the other end. He just loves scoring runs. He's a huge asset for the club."
Hampshire coach Craig White:
"We'll assess Fidel Edwards' injury in the morning, but it looks a bit sore and he'll struggle to take a further part in the game.
"Every game it seems this year we've had a bowler go down. It's not ideal, it's just frustrating. Injuries happen I know but when it happens every game and you're a bowler down you wonder if you're doing something wrong."
"It was a frustrating day. At the start we wouldn't have thought they'd only be two wickets down at the end of play. I'm a little bit shocked really. It was great conditions to bowl in and we probably early on didn't get enough balls consistently in the right areas. But you have to take your hat off to those two. They played really well."
Alastair Cook and Tom Westley both hit centuries as Essex took charge on a rain-affected first day against Hampshire in the County Championship.