How can I assign a URL with a fragment (#) as an array value?
You can use an array for $form_state['redirect'], the elements of which mirror the arguments passed to the url() function.

So you can use...

$form_state['redirect'] = array(
  "mypage/$nid",
  array('fragment' =&gt; 'comment-form'),
);


The method it used quite sparingly in core (just 5 occurrences as far as I can tell); node_form_delete_submit() contains an example.